/* ============================================================
   HAMYAR — DESIGN SYSTEM 2.0
   Dark, glassmorphic, modern SaaS UI
   ============================================================ */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg:        #07090f;
  --surface:   rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --surface-3: rgba(255, 255, 255, 0.11);

  --border:   rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);

  --text:  #e2eaf7;
  --ink:   #c0cfe8;
  --muted: #5a6f8a;

  --teal:         #0dd9be;
  --teal-2:       #2de8d0;
  --teal-soft:    rgba(13, 217, 190, 0.10);
  --indigo:       #8175f9;
  --indigo-2:     #9d93fb;
  --indigo-soft:  rgba(129, 117, 249, 0.12);
  --pink:         #e8368a;
  --pink-soft:    rgba(232, 54, 138, 0.10);
  --coral:        #ff6b70;
  --gold:         #f5be41;
  --gold-soft:    rgba(245, 190, 65, 0.11);
  --emerald:      #28d980;
  --emerald-soft: rgba(40, 217, 128, 0.10);

  --danger:       #f56565;
  --danger-soft:  rgba(245, 101, 101, 0.11);
  --success:      #28d980;
  --success-soft: rgba(40, 217, 128, 0.10);

  --shadow-xs: 0 1px 4px rgba(0, 0, 0, 0.50);
  --shadow:    0 4px 20px rgba(0, 0, 0, 0.55), 0 1px 6px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.65), 0 6px 24px rgba(0, 0, 0, 0.45);
  --glow-teal:   0 0 50px rgba(13, 217, 190, 0.13), 0 0 18px rgba(13, 217, 190, 0.09);
  --glow-indigo: 0 0 50px rgba(129, 117, 249, 0.13), 0 0 18px rgba(129, 117, 249, 0.09);

  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  24px;
  --r-full: 999px;
}

/* ── RESET ──────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(ellipse at 5%   5%,  rgba(129, 117, 249, 0.18) 0%, transparent 42%),
    radial-gradient(ellipse at 95%  5%,  rgba(13, 217, 190, 0.14)  0%, transparent 40%),
    radial-gradient(ellipse at 50%  98%, rgba(232, 54, 138, 0.10)  0%, transparent 40%),
    var(--bg);
  background-attachment: fixed;
}

html[dir="rtl"] body {
  font-family: Vazirmatn, IRANSans, Dana, Estedad, Shabnam,
    "Segoe UI", Tahoma, Inter, ui-sans-serif, system-ui, sans-serif;
}

button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
.is-hidden { display: none !important; }

/* ── FORM ELEMENTS ──────────────────────────────────────────── */
input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 10px 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input::placeholder,
textarea::placeholder { color: var(--muted); }

textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13, 217, 190, 0.15), 0 0 24px rgba(13, 217, 190, 0.08);
  background: rgba(255, 255, 255, 0.07);
}

select option {
  background: #131826;
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ── BUTTONS ────────────────────────────────────────────────── */
button {
  cursor: pointer;
  border-radius: var(--r-full);
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    opacity 0.18s ease, filter 0.18s ease;
}

button:hover  { transform: translateY(-1px); }
button:active { transform: translateY(0); }

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none !important;
  pointer-events: none;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.login-form button,
.primary,
.connect-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: none;
  border-radius: var(--r-full);
  padding: 0 22px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  background: linear-gradient(135deg, #0dd9be 0%, #8175f9 55%, #e8368a 100%);
  color: #fff;
  box-shadow:
    0 4px 20px rgba(13, 217, 190, 0.28),
    0 0  50px rgba(129, 117, 249, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.login-form button:hover,
.primary:hover,
.connect-link:hover {
  filter: brightness(1.10) saturate(1.06);
  box-shadow:
    0 8px 28px rgba(13, 217, 190, 0.36),
    0 0  60px rgba(129, 117, 249, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  padding: 0 22px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  backdrop-filter: blur(8px);
}

.secondary:hover {
  border-color: var(--teal);
  background: rgba(13, 217, 190, 0.08);
  color: var(--teal-2);
}

.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid rgba(245, 101, 101, 0.28);
  border-radius: var(--r-full);
  padding: 0 22px;
  font-size: 14px;
  font-weight: 700;
  background: var(--danger-soft);
  color: var(--danger);
}

.danger:hover {
  border-color: var(--danger);
  background: rgba(245, 101, 101, 0.18);
}

.small {
  min-height: 34px !important;
  padding: 0 14px !important;
  font-size: 13px !important;
}

button.is-loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

html[dir="rtl"] button.is-loading::before {
  margin-right: 0;
  margin-left: 8px;
}

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

/* ── BOOT SCREEN ────────────────────────────────────────────── */
.booting [data-auth-screen],
.booting [data-app] { display: none; }

.boot-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  gap: 16px;
  color: var(--muted);
}

.boot-screen .app-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  animation: pulse-glow 2.4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow:
      0 0 40px rgba(13, 217, 190, 0.22),
      0 0 80px rgba(129, 117, 249, 0.15);
  }
  50% {
    box-shadow:
      0 0 60px rgba(13, 217, 190, 0.40),
      0 0 120px rgba(129, 117, 249, 0.28);
  }
}

/* ── LOGIN SCREEN ───────────────────────────────────────────── */
.login-screen {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(360px, 1fr);
  gap: 20px;
  width: min(1180px, calc(100% - 40px));
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 24px 0;
  align-items: center;
  overflow: hidden;
}

.login-panel,
.login-visual,
.panel,
.approval-item,
.asset-card {
  border: 1px solid var(--border-2);
  border-radius: var(--r-2xl);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(24px) saturate(140%);
}

.login-panel {
  max-height: calc(100dvh - 48px);
  padding: 36px;
  overflow-y: auto;
  scrollbar-width: none;
}
.login-panel::-webkit-scrollbar { display: none; }

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup.compact {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow:
    0 0 28px rgba(13, 217, 190, 0.22),
    0 6px 18px rgba(0, 0, 0, 0.45);
}

.small-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-lockup h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e2eaf7 20%, #0dd9be 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-lockup p,
.brand-lockup small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  -webkit-text-fill-color: var(--muted);
}

/* Auth tabs */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 28px;
  padding: 4px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.auth-tabs button.is-active {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.30);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-form input { min-height: 46px; font-size: 15px; }

.login-form button {
  min-height: 50px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
}

.form-message,
.helper {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

/* Login visual */
.login-visual {
  position: relative;
  height: min(720px, calc(100dvh - 48px));
  min-height: 520px;
  overflow: hidden;
  background: #0c0e1a;
}

.login-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.82;
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(13, 217, 190, 0.28) 0%, transparent 52%),
    radial-gradient(ellipse at 75% 70%, rgba(232, 54, 138, 0.24) 0%, transparent 52%),
    linear-gradient(180deg,
      rgba(7, 9, 15, 0.28) 0%,
      rgba(7, 9, 15, 0.00) 38%,
      rgba(7, 9, 15, 0.80) 100%);
  pointer-events: none;
  z-index: 1;
}

.approval-strip {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 5px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: rgba(7, 9, 15, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(18px);
  z-index: 2;
}

.approval-strip span {
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.approval-strip strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

/* ── APP SHELL ──────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(7, 9, 15, 0.90);
  backdrop-filter: blur(24px);
  overflow: hidden;
}

/* Gradient right-edge accent line */
.sidebar::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; right: -1px;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(13, 217, 190, 0.40) 35%,
    rgba(129, 117, 249, 0.30) 65%,
    transparent 100%
  );
  pointer-events: none;
}

.nav-list {
  display: grid;
  gap: 3px;
  padding: 12px 10px;
  flex: 1;
  align-content: start;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
  transform: none;
}

.nav-item.is-active {
  background: rgba(13, 217, 190, 0.09);
  border-color: rgba(13, 217, 190, 0.22);
  color: var(--teal);
  box-shadow: 0 0 22px rgba(13, 217, 190, 0.08);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}

.nav-item.is-active svg { opacity: 1; }
.nav-item:hover svg     { opacity: 0.90; }

.connect-link:not(.inline) {
  width: calc(100% - 20px);
  margin: 8px 10px;
}

.connect-link.inline {
  width: fit-content;
  margin: 18px 0 0;
}

.logout {
  margin: 8px 10px 16px;
  width: calc(100% - 20px);
  align-self: flex-end;
}

/* ── MAIN & TOPBAR ──────────────────────────────────────────── */
.main {
  min-width: 0;
  padding: 28px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}

.topbar h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
}

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

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
}

.language-switch button {
  min-width: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.language-switch button.is-active {
  background: rgba(13, 217, 190, 0.12);
  color: var(--teal);
}

/* ── PILLS / STATE / KIND ───────────────────────────────────── */
.pill, .state, .kind {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: var(--r-full);
  padding: 0 10px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.state.muted { background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.kind        { background: var(--gold-soft); color: var(--gold); }

/* ── FLASH MESSAGES ─────────────────────────────────────────── */
.flash {
  margin-bottom: 20px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  padding: 13px 16px;
  font-weight: 600;
  line-height: 1.45;
  box-shadow: var(--shadow);
  animation: flash-in 0.22s ease;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.flash.is-success {
  border-color: rgba(40, 217, 128, 0.28);
  background: rgba(40, 217, 128, 0.08);
  color: #5ddb9a;
}

.flash.is-warning {
  border-color: rgba(245, 190, 65, 0.28);
  background: rgba(245, 190, 65, 0.08);
  color: var(--gold);
}

.flash.is-error {
  border-color: rgba(245, 101, 101, 0.28);
  background: rgba(245, 101, 101, 0.08);
  color: var(--danger);
}

/* ── TAB PANELS ─────────────────────────────────────────────── */
.tab-panel { display: none; }

.tab-panel.is-active {
  display: block;
  animation: panel-fade 0.22s ease;
}

@keyframes panel-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ── GRID LAYOUTS ───────────────────────────────────────────── */
.metric-grid,
.work-grid,
.prompt-layout,
.asset-grid {
  display: grid;
  gap: 16px;
}

.metric-grid   { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.work-grid     { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.prompt-layout { grid-template-columns: minmax(0, 1fr); }

/* ── PANEL ──────────────────────────────────────────────────── */
.panel,
.metric,
.approval-item,
.asset-card {
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

/* Gradient shimmer line on top of every card */
.panel::after,
.asset-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(13, 217, 190, 0.55),
    rgba(129, 117, 249, 0.45),
    transparent
  );
  pointer-events: none;
}

.panel       { padding: 20px; }
.panel.wide  { min-width: 0; }

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

.panel-head.compact { margin-bottom: 0; }

.panel h3,
.approval-item h3,
.asset-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.panel-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── METRIC ─────────────────────────────────────────────────── */
.metric {
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}

.metric span,
.metric small,
.summary-list dt,
.asset-card p,
.approval-item p { color: var(--muted); font-size: 13px; }

.metric strong { font-size: 28px; font-weight: 800; color: var(--text); }

/* ── PROFILE TAB ────────────────────────────────────────────── */
.toggle-grid { display: grid; gap: 10px; }

.switch-row {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  padding: 9px 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.switch-row:hover {
  border-color: rgba(13, 217, 190, 0.32);
  background: var(--teal-soft);
}

.switch-row input  { width: 18px; min-height: 18px; accent-color: var(--teal); }
.switch-row span   { min-width: 0; color: var(--ink); font-weight: 600; }

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

.summary-list { display: grid; gap: 10px; margin: 0; }
.summary-list.compact { margin-top: 16px; }

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.summary-list dd { margin: 0; font-weight: 700; text-align: right; color: var(--ink); }

/* ── PROMPTS TAB ────────────────────────────────────────────── */
.prompt-layout textarea[data-field="dm_prompt"] {
  min-height: min(58vh, 560px);
  font-size: 15px;
}

.prompt-counter  { margin-top: 8px; text-align: right; font-size: 12px; color: var(--muted); }

.dm-qa-section {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.dm-qa-list { display: grid; gap: 12px; }

.dm-qa-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid rgba(13, 217, 190, 0.14);
  border-radius: var(--r-lg);
  background: rgba(13, 217, 190, 0.04);
  padding: 14px;
  transition: border-color 0.15s ease;
}

.dm-qa-card:hover { border-color: rgba(13, 217, 190, 0.28); }
.dm-qa-card textarea { min-height: 88px; resize: vertical; }

/* ── INSTAGRAM TAB ──────────────────────────────────────────── */
.instagram-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(380px, 1.1fr);
  gap: 16px;
}

.instagram-connect-panel,
.instagram-setup-panel { min-height: 100%; }

.instagram-handoff-panel { grid-column: 1 / -1; }

.connection-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
  margin-bottom: 14px;
}

.connection-orb {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #d8447b, #f5a436);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(216, 68, 123, 0.35);
}

.instagram-status { min-height: 44px; color: var(--muted); line-height: 1.5; font-size: 14px; }

.connected-account-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid rgba(232, 54, 138, 0.22);
  border-radius: var(--r-lg);
  background: rgba(232, 54, 138, 0.06);
  box-shadow: 0 8px 30px rgba(232, 54, 138, 0.10);
}

.connected-account-avatar {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0.06em;
  font-size: 16px;
  background: linear-gradient(135deg, #feda75, #fa7e1e 30%, #d62976 62%, #962fbf);
  box-shadow: 0 10px 28px rgba(214, 41, 118, 0.40);
}

.connected-account-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.connected-account-info strong { display: block; margin-bottom: 10px; color: var(--text); }
.connected-account-info dl { display: grid; gap: 8px; margin: 0; }

.connected-account-info dl div {
  display: grid;
  grid-template-columns: minmax(110px, 0.45fr) 1fr;
  gap: 10px;
  align-items: baseline;
}

.connected-account-info dt { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.connected-account-info dd { margin: 0; color: var(--ink); font-weight: 700; overflow-wrap: anywhere; }
.instagram-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.setup-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.setup-steps li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px;
  transition: border-color 0.15s ease;
}

.setup-steps li:hover { border-color: rgba(13, 217, 190, 0.26); }

.setup-steps li > span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
  font-size: 14px;
}

.setup-steps strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.setup-steps p      { color: var(--muted); line-height: 1.45; font-size: 13px; }

.setup-note {
  margin-top: 12px;
  border: 1px solid rgba(245, 190, 65, 0.24);
  border-radius: var(--r-sm);
  background: rgba(245, 190, 65, 0.07);
  color: var(--gold);
  padding: 12px;
  line-height: 1.5;
  font-weight: 600;
  font-size: 13px;
}

.permission-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(13, 217, 190, 0.16);
  border-radius: var(--r-sm);
  background: rgba(13, 217, 190, 0.05);
  padding: 12px;
}

.permission-list strong { color: var(--ink); font-size: 13px; }

.permission-list code {
  display: block;
  white-space: normal;
  word-break: break-word;
  color: var(--teal-2);
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.customer-disable-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: rgba(13, 217, 190, 0.04);
}

.handoff-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.handoff-summary-card {
  display: grid;
  gap: 4px;
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px;
}

.handoff-summary-card strong { font-size: 26px; line-height: 1; color: var(--teal); }
.handoff-summary-card span   { color: var(--muted); font-size: 12px; font-weight: 600; }

.handoff-list { display: grid; gap: 12px; }

.handoff-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  border-left: 4px solid var(--teal);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.handoff-card:hover    { box-shadow: var(--glow-teal); }
.handoff-card.is-limit  { border-left-color: var(--gold); }
.handoff-card.is-manual { border-left-color: var(--coral); }

.handoff-body { min-width: 0; display: grid; gap: 8px; }

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

.handoff-topline h3 { margin: 0; font-size: 15px; color: var(--text); }

.handoff-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: var(--r-full);
  padding: 0 10px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
}

.is-limit .handoff-badge  { background: var(--gold-soft);   color: var(--gold); }
.is-manual .handoff-badge { background: var(--danger-soft); color: var(--coral); }

.handoff-body p  { color: var(--ink); line-height: 1.45; font-size: 14px; }
.handoff-meta { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }

.empty-state {
  border: 1px dashed var(--border-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--muted);
  padding: 24px;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}

/* ── ACCOUNTING TAB ─────────────────────────────────────────── */
.accounting-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.accounting-stat {
  display: grid;
  gap: 7px;
  min-height: 112px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.accounting-stat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}

.accounting-stat.is-customers::before    { background: #6366f1; }
.accounting-stat.is-purchase::before     { background: #a855f7; }
.accounting-stat.is-sale::before         { background: #0ea5e9; }
.accounting-stat.is-received::before     { background: #22c55e; }
.accounting-stat.is-balance::before      { background: #f97316; }
.accounting-stat.is-profit::before       { background: #22c55e; }
.accounting-stat.is-extra-profit::before  { background: #8b5cf6; }
.accounting-stat.is-total-profit::before  { background: #0dd9be; }

.accounting-stat span,
.accounting-stat small { color: var(--muted); font-size: 12px; font-weight: 600; }

.accounting-stat strong { font-size: 22px; font-weight: 800; color: var(--text); line-height: 1.1; }

.accounting-report-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(12px);
}

.accounting-report-bar label { min-width: 180px; }

.accounting-report-row {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.4fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 16px;
}

.accounting-profit-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.accounting-profit-panel { min-height: 100%; }
.accounting-customer-panel { min-width: 0; margin-bottom: 16px; }

.accounting-customer-directory {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.accounting-customer-browser { min-width: 0; }
.accounting-layout { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }

.customer-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
  max-width: 1080px;
}

.customer-profit-card,
.customer-extra-profit-card,
.customer-total-profit-card,
.customer-debt-card {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(40, 217, 128, 0.20);
  border-radius: var(--r-lg);
  background: rgba(40, 217, 128, 0.06);
  padding: 14px;
  box-shadow: 0 6px 22px rgba(40, 217, 128, 0.08);
}

.customer-extra-profit-card {
  border-color: rgba(139, 92, 246, 0.22);
  background: rgba(139, 92, 246, 0.06);
  box-shadow: 0 6px 22px rgba(139, 92, 246, 0.08);
}

.customer-total-profit-card {
  border-color: rgba(13, 217, 190, 0.22);
  background: rgba(13, 217, 190, 0.06);
  box-shadow: 0 6px 22px rgba(13, 217, 190, 0.08);
}

.customer-debt-card {
  border-color: rgba(249, 115, 22, 0.22);
  background: rgba(249, 115, 22, 0.06);
  box-shadow: 0 6px 22px rgba(249, 115, 22, 0.08);
}

.customer-profit-card span,      .customer-profit-card small,
.customer-extra-profit-card span, .customer-extra-profit-card small,
.customer-total-profit-card span, .customer-total-profit-card small,
.customer-debt-card span,         .customer-debt-card small {
  color: var(--muted); font-size: 12px; font-weight: 600;
}

.customer-profit-card strong,
.customer-extra-profit-card strong,
.customer-total-profit-card strong,
.customer-debt-card strong { font-size: 20px; line-height: 1.1; }

.customer-profit-card strong        { color: #4ade80; }
.customer-extra-profit-card strong  { color: #a78bfa; }
.customer-total-profit-card strong  { color: var(--teal-2); }
.customer-debt-card strong          { color: #fb923c; }

.accounting-sidebar { position: sticky; top: 24px; }

.accounting-customer-form,
.accounting-entry-form {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
}

.accounting-entry-form { margin-bottom: 16px; }
.accounting-customer-form textarea { min-height: 72px; }
.accounting-search { margin-bottom: 12px; }

.accounting-customer-panel .accounting-customer-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.accounting-entry-search { margin: 2px 0 4px; }

.accounting-customer-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "avatar body"
    "avatar balance";
  align-items: center;
  gap: 8px 12px;
  width: 100%;
  min-height: 88px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  padding: 13px;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.accounting-customer-card:hover {
  border-color: rgba(13, 217, 190, 0.30);
  background: rgba(13, 217, 190, 0.05);
  box-shadow: 0 0 26px rgba(13, 217, 190, 0.08);
  transform: none;
}

.accounting-customer-card.is-active {
  border-color: rgba(13, 217, 190, 0.45);
  background: rgba(13, 217, 190, 0.08);
  outline: 2px solid rgba(13, 217, 190, 0.12);
  outline-offset: 0;
}

.accounting-customer-avatar {
  grid-area: avatar;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #6366f1, #0dd9be);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.30);
}

.accounting-customer-body { grid-area: body; display: grid; gap: 3px; min-width: 0; }

.accounting-customer-body strong,
.accounting-customer-body span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.accounting-customer-body strong { color: var(--text); font-size: 14px; }

.accounting-customer-card span,
.accounting-customer-card small  { color: var(--muted); font-size: 12px; }

.accounting-customer-card > small {
  grid-area: balance;
  width: fit-content;
  border-radius: var(--r-full);
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.accounting-customer-card small.owes    { color: #fb923c; font-weight: 700; }
.accounting-customer-card small.you-owe { color: #60a5fa; font-weight: 700; }
.accounting-customer-card small.settled { color: #4ade80; font-weight: 700; }

.accounting-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 300px;
  gap: 8px;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.accounting-empty strong { color: var(--ink); font-size: 18px; }
.accounting-ledger { display: grid; gap: 14px; }

.accounting-mini-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.accounting-mini-stats button {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  text-align: start;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.accounting-mini-stats button:hover,
.accounting-mini-stats button.is-active {
  transform: translateY(-1px);
  border-color: rgba(13, 217, 190, 0.30);
  box-shadow: 0 8px 20px rgba(13, 217, 190, 0.09);
}

.accounting-mini-stats strong { color: var(--text); font-size: 15px; }

.accounting-mini-stats .is-purchase  { background: rgba(168, 85,  247, 0.07); }
.accounting-mini-stats .is-sale      { background: rgba(14,  165, 233, 0.07); }
.accounting-mini-stats .is-received  { background: rgba(34,  197, 94,  0.07); }
.accounting-mini-stats .is-sent      { background: rgba(239, 68,  68,  0.07); }
.accounting-mini-stats .is-balance   { background: rgba(249, 115, 22,  0.07); }

.accounting-entry-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-color: rgba(139, 92, 246, 0.18);
  background: rgba(139, 92, 246, 0.04);
}

.accounting-entry-form .wide { grid-column: 1 / -1; }
.accounting-entry-form textarea { min-height: 76px; }

.accounting-entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-left: 4px solid #475569;
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px;
}

.accounting-entry-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.delivery-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--r-full);
  background: rgba(40, 217, 128, 0.08);
  color: #4ade80;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(40, 217, 128, 0.20);
  transition: background 0.15s ease;
}

.delivery-toggle:hover { background: rgba(40, 217, 128, 0.14); }
.delivery-toggle input { width: auto; accent-color: var(--success); }

.accounting-entry-card.is-purchase        { border-left-color: #a855f7; background: rgba(168, 85,  247, 0.04); }
.accounting-entry-card.is-customer_sale   { border-left-color: #0ea5e9; background: rgba(14,  165, 233, 0.04); }
.accounting-entry-card.is-money_received  { border-left-color: #22c55e; background: rgba(34,  197, 94,  0.04); }
.accounting-entry-card.is-money_sent      { border-left-color: #ef4444; background: rgba(239, 68,  68,  0.04); }
.accounting-entry-card.is-note            { border-left-color: #f59e0b; background: rgba(245, 158, 11,  0.04); }

.accounting-entry-card h3   { margin-bottom: 4px; color: var(--text); font-size: 14px; }
.accounting-entry-card p    { color: var(--ink); font-weight: 700; }
.accounting-entry-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }

/* ── APPROVALS / STORY+POST ─────────────────────────────────── */
.approval-item {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  box-shadow: var(--shadow-xs);
}

.approval-media {
  min-height: 150px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: #0c0e1a;
}

.approval-media.is-story  { aspect-ratio: 9 / 16; }

.approval-media img,
.approval-media video { width: 100%; height: 100%; display: block; object-fit: cover; }

.approval-body   { min-width: 0; display: grid; align-content: center; gap: 6px; }
.approval-body small { color: var(--muted); font-size: 12px; }
.approval-status { text-transform: capitalize; font-weight: 700; color: var(--text); }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.coming-soon-copy {
  display: grid;
  min-height: 88px;
  place-items: center;
  border: 1px dashed rgba(13, 217, 190, 0.22);
  border-radius: var(--r-md);
  background: rgba(13, 217, 190, 0.04);
  color: var(--teal);
  font-size: 18px;
  font-weight: 800;
}

.coming-soon-panel { position: relative; }

/* ── SECURITY TAB ───────────────────────────────────────────── */
.session-list { display: grid; gap: 10px; }

.session-item,
.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px 16px;
  transition: border-color 0.15s ease;
}

.session-item:hover,
.user-card:hover { border-color: var(--border-2); }

.session-item h3 { font-size: 14px; color: var(--text); }

.session-item p,
.user-card p {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
  font-size: 13px;
}

/* ── USERS TAB ──────────────────────────────────────────────── */
.admin-user-form { display: grid; gap: 12px; }
.user-list { display: grid; gap: 10px; }
.source-list, .approval-list { display: grid; gap: 10px; }

.source-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 100px;
  align-items: center;
  gap: 12px;
}

.source-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px;
}

.source-editor { margin-bottom: 12px; }

.source-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.source-details { min-width: 0; display: grid; gap: 4px; }

.source-details strong,
.source-details span,
.source-details small {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.source-details strong { font-size: 17px; color: var(--ink); }
.source-details span   { color: var(--muted); }

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 0 10px;
}

.product-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 10px;
}

.product-item img  { width: 72px; height: 72px; border-radius: 7px; object-fit: cover; background: #101820; }
.product-item h3   { font-size: 15px; color: var(--text); }
.product-item p    { margin-top: 4px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── MISC ───────────────────────────────────────────────────── */
pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: #0a0d17;
  color: #a8d0e0;
  padding: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  font-size: 13px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.agent-output { margin-top: 14px; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1120px) {
  .metric-grid,
  .asset-grid,
  .rate-grid,
  .accounting-stats,
  .accounting-mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .work-grid,
  .accounting-report-row,
  .accounting-profit-breakdown,
  .accounting-customer-directory,
  .accounting-layout { grid-template-columns: 1fr; }

  .accounting-sidebar { position: static; }
  .instagram-grid     { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .login-screen,
  .app-shell { display: block; }

  .login-screen {
    min-height: auto; height: auto; overflow: visible; padding: 16px; width: 100%;
  }

  .login-panel { padding: 24px; }

  .login-visual { height: auto; min-height: 320px; margin-top: 16px; }
  .login-visual img { min-height: 320px; }

  .connected-account-card,
  .connected-account-info dl div { grid-template-columns: 1fr; }

  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar::after { display: none; }

  .nav-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .main { padding: 16px 18px; }

  .topbar,
  .session-item,
  .user-card { align-items: flex-start; flex-direction: column; }

  .topbar-actions { width: 100%; }

  .metric-grid,    .prompt-layout,     .dm-qa-card,
  .asset-grid,     .rate-grid,         .accounting-stats,
  .accounting-mini-stats, .customer-summary-cards,
  .accounting-entry-form, .approval-item,
  .customer-disable-form, .handoff-summary-grid,
  .handoff-card,   .accounting-entry-card,
  .source-card,    .source-row { grid-template-columns: 1fr; }

  .approval-actions { width: 100%; justify-content: flex-start; }
}

/* ── RTL ────────────────────────────────────────────────────── */
html[dir="rtl"] .nav-item,
html[dir="rtl"] .summary-list dd { text-align: right; }

html[dir="rtl"] .sidebar {
  border-right: 0;
  border-left: 1px solid var(--border);
}

html[dir="rtl"] .sidebar::after {
  right: auto;
  left: -1px;
}

html[dir="rtl"] .handoff-card,
html[dir="rtl"] .accounting-entry-card {
  border-left-width: 1px;
  border-right: 4px solid;
}

html[dir="rtl"] .handoff-card          { border-right-color: var(--teal); }
html[dir="rtl"] .handoff-card.is-limit  { border-right-color: var(--gold); }
html[dir="rtl"] .handoff-card.is-manual { border-right-color: var(--coral); }
