@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Vazirmatn:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0f0f13;
  --bg-elevated: #18181f;
  --bg-card: #1c1c24;
  --bg-hover: #252530;
  --text: #f4f4f5;
  --text-muted: #a1a1aa;
  --border: #27272a;
  --accent: #8b5cf6;
  --accent-2: #6366f1;
  --accent-soft: rgba(139, 92, 246, 0.12);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f4f4f5;
  --text: #09090b;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { max-width: 100%; overflow-x: hidden; }
body { font-family: 'Inter', 'Vazirmatn', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; max-width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
.loading-overlay.show { display: flex; }
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: white; font-weight: 500; font-size: 0.95rem; }

/* Toast Alerts */
.toast-container {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
  width: min(420px, calc(100% - 1.25rem));
}
.toast {
  pointer-events: auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.9rem 1.2rem;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.92rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
}
.toast.success { background: rgba(34, 197, 94, 0.95); color: white; }
.toast.error { background: rgba(239, 68, 68, 0.95); color: white; }
.toast.info { background: rgba(139, 92, 246, 0.95); color: white; }
.toast.warning { background: rgba(245, 158, 11, 0.95); color: white; }
.toast .close {
  margin-right: auto;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.8;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

/* App Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  top: 0; right: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-header { padding: 1.35rem 1.15rem; border-bottom: 1px solid var(--border); }
.brand, .topbar-brand { display: flex; align-items: center; gap: 0.7rem; }
.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand strong { display: block; font-size: 1rem; line-height: 1.2; }
.brand small { color: var(--text-muted); font-size: 0.72rem; }
.topbar-brand img { width: 36px; height: 36px; border-radius: 10px; }
.topbar-brand span { font-weight: 800; font-size: 1.05rem; }
.nav { padding: 0.8rem 0.75rem; flex: 1; overflow: auto; }
.nav-label { margin: 0.85rem 0.7rem 0.35rem; font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.04em; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.62rem 0.7rem; margin-bottom: 0.2rem;
  border-radius: 12px; color: var(--text-muted);
  text-decoration: none; font-weight: 600; cursor: pointer;
  transition: var(--transition); border: none; background: transparent;
  width: 100%; text-align: right; font-size: 0.92rem; font-family: inherit;
}
.nav-item i { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); font-style: normal; color: var(--text); }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active i { background: var(--accent); color: #fff; }
.sidebar-foot { padding: 0.8rem; border-top: 1px solid var(--border); }
.sidebar-foot button { width: 100%; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 12px; padding: 0.7rem; cursor: pointer; font-family: inherit; }
.main { flex: 1; margin-right: 260px; padding: 1.5rem 2rem 3rem; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.75rem; }
.menu-btn, .theme-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; width: 42px; height: 42px; font-size: 1.15rem;
  cursor: pointer; color: var(--text); display: none;
}
.theme-btn { display: flex; align-items: center; justify-content: center; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 90; opacity: 0; visibility: hidden; transition: 0.3s; }
.overlay.show { opacity: 1; visibility: visible; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.stat.accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: white; }
.stat .label { font-size: 0.85rem; opacity: 0.8; margin-bottom: 0.35rem; }
.stat .value { font-size: 1.75rem; font-weight: 800; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 1.4rem; border-radius: var(--radius-sm); font-weight: 600; border: none; cursor: pointer; font-size: 0.9rem; font-family: inherit; transition: var(--transition); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 1.2rem; }
.form-label { display: block; font-weight: 600; margin-bottom: 0.45rem; font-size: 0.88rem; color: var(--text-muted); }
.form-control, .form-select, textarea { width: 100%; padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: 0.95rem; font-family: inherit; }
.form-control:focus, .form-select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }

.page-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 1.5rem; }
.profit { color: var(--success); font-weight: 700; }
.loss { color: var(--danger); font-weight: 700; }
.steps { display: flex; gap: 0.4rem; margin-bottom: 1.5rem; overflow-x: auto; }
.step { flex: 1; min-width: 70px; text-align: center; padding: 0.55rem 0.3rem; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); font-size: 0.75rem; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.step.active { background: var(--accent); color: white; border-color: var(--accent); }
.step.done { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.step-panel { display: none; }
.step-panel.active { display: block; }
.wizard-actions { display: flex; justify-content: space-between; margin-top: 1.5rem; gap: 0.75rem; flex-wrap: wrap; }
.checklist { background: var(--accent-soft); border-radius: 12px; padding: 1rem 1.25rem; margin: 1rem 0; }
.check-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.check-item:last-child { border-bottom: none; }
.badge { display: inline-block; padding: 0.25rem 0.65rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-long { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-short { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem 1rem; text-align: right; }
th { font-size: 0.75rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }
@media (max-width: 800px) { .wizard-actions { flex-direction: column; } .wizard-actions .btn { width: 100%; } }

@media (max-width: 800px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-right: 0; padding: 1rem; }
  .menu-btn { display: flex; align-items: center; justify-content: center; }
  .form-row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
}
body.auth-page .sidebar, body.auth-page .topbar, body.auth-page .overlay { display: none; }
body.auth-page .main { margin: 0; padding: 0; min-height: 100vh; }
.req { color: var(--danger); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.4rem; background: radial-gradient(circle at top, rgba(124,58,237,.28), transparent 42%), var(--bg); }
.auth-card { width: min(440px, 100%); background: var(--bg-card); border: 1px solid var(--border); border-radius: 24px; padding: 1.4rem; box-shadow: 0 20px 50px rgba(0,0,0,.12); }
.auth-logo { width: 64px; height: 64px; border-radius: 18px; display: block; margin: 0 auto 0.6rem; }
.auth-card h1 { margin: 0; text-align: center; font-size: 1.45rem; }
.auth-sub { text-align: center; color: var(--text-muted); margin: 0.4rem 0 1rem; line-height: 1.7; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; background: var(--bg); padding: 0.3rem; border-radius: 14px; margin-bottom: 1rem; }
.auth-tabs button { border: 0; background: transparent; color: var(--text-muted); border-radius: 11px; padding: 0.65rem; cursor: pointer; font-family: inherit; font-weight: 700; }
.auth-tabs button.on { background: var(--bg-card); color: var(--text); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.auth-submit { width: 100%; margin-bottom: 0.8rem; }
.auth-links { display: flex; justify-content: space-between; gap: 0.8rem; margin: 0.4rem 0 0; }
.auth-links a { color: var(--accent); text-decoration: none; font-weight: 700; }

.check-view { margin: 0.45rem 0 0; padding-right: 1.1rem; color: var(--text); }
.check-view li { margin: 0.25rem 0; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
tr.detail-row td { background: var(--bg); padding: 0.85rem 1rem 1.15rem; }
.whatif-box { margin: 0.4rem 0 1rem; padding: 0.9rem 1rem 0.2rem; border: 1px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); }
.trade-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.modal-back { position: fixed; inset: 0; z-index: 10003; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(8, 8, 12, 0.72); }
.modal-back.show { display: flex; }
.whatif-modal { width: min(440px, 100%); margin: 0; }
.whatif-modal h3 { margin-bottom: 0.8rem; }
.edit-modal { width: min(760px, 100%); max-height: min(92vh, 920px); overflow: auto; margin: 0; position: relative; }
.edit-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.edit-head h3 { margin: 0; }
.edit-head .shot-close { position: static; }
.edit-sub { color: var(--text-muted); margin: 0.35rem 0 1rem; }
.edit-section { margin-bottom: 0.4rem; }
.edit-section h4 { font-size: 0.78rem; letter-spacing: 0.02em; color: var(--accent); margin-bottom: 0.7rem; }
.edit-shot-wrap { margin-bottom: 0.55rem; }
.edit-shot { display: block; width: 100%; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); cursor: zoom-in; }
.edit-shot img { display: block; width: 100%; height: 160px; object-fit: cover; }
.edit-empty, .edit-hint { color: var(--text-muted); font-size: 0.78rem; }
.edit-hint { display: block; margin-top: 0.35rem; }
.td-whatif strong { font-size: 0.82rem; }
.td-whatif span { font-weight: 700; }
.td-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 0.6rem; }
.td-metric { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.85rem; }
.td-metric span { display: block; color: var(--text-muted); font-size: 0.72rem; margin-bottom: 0.28rem; }
.td-metric strong { font-size: 0.95rem; font-weight: 700; }
.td-split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 0.75rem; }
.td-block { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; }
.td-block h4 { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.65rem; }
.td-checks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.28rem 0.6rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: 0.78rem; }
.chip.ok { background: rgba(34, 197, 94, 0.12); color: var(--success); border-color: transparent; }
.chip.no { background: rgba(239, 68, 68, 0.12); color: var(--danger); border-color: transparent; }
.td-notes { white-space: pre-wrap; line-height: 1.7; color: var(--text); font-size: 0.9rem; }
.td-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.td-shot { margin: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.td-shot figcaption { padding: 0.55rem 0.8rem; font-size: 0.75rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.td-shot img { display: block; width: 100%; height: 220px; object-fit: cover; background: var(--bg); }
.shot-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.shot-lightbox {
  position: fixed; inset: 0; z-index: 10002; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 0.75rem;
  background: rgba(8, 8, 12, 0.88); padding: 1.25rem;
}
.shot-lightbox.show { display: flex; }
.shot-lightbox img { max-width: min(960px, 94vw); max-height: 82vh; object-fit: contain; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.shot-lightbox p { color: #fff; font-size: 0.9rem; }
.shot-close {
  position: absolute; top: 0.8rem; left: 0.8rem; width: 42px; height: 42px;
  border: 0; border-radius: 12px; background: rgba(255,255,255,0.12); color: #fff;
  font-size: 1.6rem; cursor: pointer;
}
.td-shot.empty div { height: 120px; display: grid; place-items: center; color: var(--text-muted); font-size: 0.85rem; }
@media (max-width: 800px) {
  .td-split, .td-shots { grid-template-columns: 1fr; }
}
.jalali-popup {
  position: fixed; z-index: 10001; display: none; width: 280px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.75rem; box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.jalali-popup.show { display: block; }
.jalali-head, .jalali-actions, .jalali-time { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.jalali-head button, .jd {
  background: transparent; color: var(--text); border: 0; cursor: pointer; border-radius: 8px;
}
.jalali-head button { font-size: 1.3rem; width: 32px; height: 32px; }
.jalali-week, .jalali-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 2px; margin-top: 0.4rem; }
.jalali-week span { color: var(--text-muted); font-size: 0.75rem; }
.jd { height: 32px; }
.jd.on { background: var(--accent); color: #fff; }
.jalali-time { margin-top: 0.6rem; }
.jalali-time input { width: 64px; margin-right: 0.3rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.3rem; }
.jalali-actions { margin-top: 0.6rem; }
[data-jalali] { cursor: pointer; }

.guide { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 0.2rem 1rem; margin: 0 0 1rem; }
.guide summary { cursor: pointer; font-weight: 700; list-style: none; padding: 0.75rem 0; display: flex; align-items: center; justify-content: space-between; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary:after { content: "▾"; opacity: .55; }
.guide:not([open]) summary:after { content: "◂"; }
.guide p { white-space: pre-wrap; color: var(--text-muted); line-height: 1.85; margin: 0 0 0.85rem; font-size: 0.92rem; }
.hint { color: var(--text-muted); font-size: 0.8rem; margin: 0.3rem 0 0.7rem; line-height: 1.6; }
.stack { display: grid; gap: 0.8rem; margin-top: 1rem; }
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.8rem 0; }
.tabs button { border: 1px solid var(--border); background: var(--bg-card); color: var(--text); border-radius: 999px; padding: 0.4rem 0.75rem; cursor: pointer; }
.tabs button.on, .phase-bar span.on { background: var(--accent); color: #fff; border-color: transparent; }
.phase-bar { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.phase-bar span { padding: 0.35rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card); font-size: 0.75rem; }
.strat-card, .cond-card { border: 1px solid var(--border); border-radius: 16px; padding: 0.9rem; margin-bottom: 0.75rem; background: var(--bg-card); }
.strat-card.ready { border-color: #16a34a; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 0.7rem; margin: 0.6rem 0; }
.img-grid figure { margin: 0; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 0.4rem; }
.img-grid img { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; display: block; background: #111; }
.img-grid .shot-open { padding: 0; border: 0; background: transparent; width: 100%; cursor: zoom-in; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 0.7rem; }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.28rem 0.55rem; border-radius: 999px; background: var(--accent-soft); border: 1px solid var(--border); font-size: 0.85rem; }
.chip button { border: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; }
.chip-add { display: flex; gap: 0.45rem; align-items: center; }
.chip-add .form-control, .chip-add .form-select { max-width: 220px; }
.picker { border: 1px dashed var(--border); border-radius: 14px; padding: 0.75rem; }
.past-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.past-head h3 { margin: 0; }
.past-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.past-grid:not(.all) .past-card:nth-child(n+5) { display: none; }
.past-card { border: 1px solid var(--border); border-radius: 14px; padding: 0.7rem; background: var(--bg); }
.past-meta { display: flex; justify-content: space-between; align-items: center; }
.past-shots { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
.past-shots img { width: 100%; height: 92px; object-fit: cover; border-radius: 8px; display: block; }
.past-shots .shot-open { padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.past-modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: flex; justify-content: center; align-items: flex-start; padding: 1.2rem; overflow: auto; }
.past-dialog { width: min(960px, 100%); background: var(--bg-card); color: var(--text); border-radius: 18px; padding: 1rem; }
@media (max-width: 700px) {
  .past-grid { grid-template-columns: 1fr; }
  .past-grid:not(.all) .past-card:nth-child(n+3) { display: none; }
}
.check-item { display: flex; gap: 0.55rem; align-items: flex-start; margin: 0.45rem 0; }
.check-item span { line-height: 1.6; }
.reval-hero { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; padding: 1.3rem 1.4rem; border-radius: 22px; background: linear-gradient(135deg, rgba(124,58,237,.95), rgba(56,189,248,.75)); color: #fff; box-shadow: 0 18px 40px rgba(124,58,237,.25); }
.reval-hero h2 { margin: 0.15rem 0; font-size: 1.55rem; }
.reval-hero p { margin: 0; max-width: 46rem; line-height: 1.7; color: rgba(255,255,255,.9); }
.eyebrow { margin: 0; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: .85; }
.iran-pill { min-width: 92px; text-align: center; padding: 0.7rem 0.9rem; border-radius: 16px; background: rgba(255,255,255,.16); font-size: 1.35rem; font-weight: 800; backdrop-filter: blur(8px); }
.phase-bar span { backdrop-filter: blur(8px); }
.strat-card h3, .cond-card h3 { margin: 0 0 0.35rem; }

.s-page { display: grid; gap: 1rem; }
.s-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.s-head h1 { margin: 0.1rem 0; font-size: 1.7rem; }
.s-head p { margin: 0; color: var(--text-muted); }
.s-list { display: grid; gap: 0.75rem; }
.s-card { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-card); }
.s-card h3 { margin: 0 0 0.45rem; }
.s-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.s-step { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.65rem; text-align: right; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); border-radius: 16px; padding: 0.75rem; cursor: pointer; }
.s-step i { grid-row: 1 / span 2; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); font-style: normal; font-weight: 800; }
.s-step b { font-size: 0.95rem; }
.s-step small { color: var(--text-muted); }
.s-step.on { border-color: var(--accent); box-shadow: 0 8px 24px rgba(124,58,237,.16); }
.s-step.on i, .s-step.done i { background: var(--accent); color: #fff; }
.s-panel { display: grid; gap: 0.8rem; }
.s-block { border: 1px solid var(--border); border-radius: 18px; padding: 1rem; background: var(--bg-card); }
.s-block > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; margin-bottom: 0.8rem; }
.s-block h3 { margin: 0; }
.s-block header p, .s-block h4 { margin: 0.2rem 0 0; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
.s-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.s-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.5rem; }
.s-actions button { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 12px; padding: 0.7rem; cursor: pointer; text-align: right; }
.s-actions button:hover { border-color: var(--accent); }
.s-cond header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; color: var(--text-muted); font-size: 0.8rem; }
.s-add { margin-top: 0.4rem; }
.s-save { display: flex; justify-content: flex-end; gap: 0.5rem; position: sticky; bottom: 0.6rem; padding: 0.7rem; border-radius: 16px; background: color-mix(in srgb, var(--bg-card) 88%, transparent); border: 1px solid var(--border); backdrop-filter: blur(10px); }
@media (max-width: 760px) {
  .s-steps, .s-grid { grid-template-columns: 1fr; }
  .s-step small { display: none; }
}

.stop-alert { margin: 0 0 1rem; padding: 0.85rem 1rem; border-radius: 14px; background: rgba(239,68,68,.12); border: 1px solid #ef4444; color: var(--text); }
tr.needs-stop { outline: 1px solid #ef4444; }
.stop-box { margin: 0.6rem 0; padding: 0.8rem; border-radius: 14px; border: 1px solid #ef4444; }
.sub-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  margin: 0.8rem 0.9rem 0.2rem; padding: 0.75rem 0.9rem; border-radius: 16px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  text-align: right; width: calc(100% - 1.8rem);
}
.sub-chip strong { font-size: 0.95rem; }
.sub-chip span { color: var(--text-muted); font-size: 0.75rem; }
.sub-chip.off { border-color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.sub-chip.top { width: auto; margin: 0; padding: 0.35rem 0.7rem; min-width: 128px; }
.topbar { gap: 0.6rem; }
.sub-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: 1rem 1.1rem; border-radius: 18px;
  background: linear-gradient(135deg, #4c1d95, #7c3aed); color: white;
}
.sub-banner p { margin: 0; opacity: 0.85; font-size: 0.85rem; }
.sub-banner strong { display: block; font-size: 1.05rem; }
.sub-hero { padding: 1.3rem 0 0.4rem; }
.sub-hero.ended h1 { color: #f8fafc; }
.sub-hero .sub-until { color: var(--text-muted); }
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-top: 1rem; }
.plan-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px; padding: 1rem; display: flex; flex-direction: column; gap: 0.45rem; }
.plan-card h2 { margin: 0; font-size: 1.05rem; }
.plan-price { margin: 0; font-size: 1.25rem; font-weight: 800; }
.sub-code-row { display: flex; gap: 0.5rem; }
.sub-code-row .form-control { flex: 1; }
@media (max-width: 900px) {
  .plan-grid { grid-template-columns: 1fr 1fr; }
  .sub-chip.top span { display: none; }
}
@media (max-width: 640px) { .plan-grid { grid-template-columns: 1fr; } }

.install-sheet {
  position: fixed; inset: 0; z-index: 10020;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0.8rem; background: rgba(8, 8, 12, 0.62); backdrop-filter: blur(8px);
}
.install-sheet[hidden] { display: none; }
.install-card {
  width: min(460px, 100%); background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 28px 28px 22px 22px;
  padding: 1.4rem 1.2rem 1.15rem; box-shadow: 0 24px 80px rgba(0,0,0,.35);
  text-align: center; position: relative;
  transform: translateY(24px); opacity: 0; transition: 0.28s ease;
}
.install-sheet.show .install-card { transform: none; opacity: 1; }
.install-card img { width: 72px; height: 72px; border-radius: 20px; box-shadow: 0 10px 30px rgba(124,58,237,.35); }
.install-kicker { margin: 0.7rem 0 0; color: var(--accent); font-size: 0.78rem; letter-spacing: 0.08em; }
.install-card h2 { margin: 0.15rem 0 0.4rem; font-size: 1.25rem; }
.install-card p { margin: 0; color: var(--text-muted); line-height: 1.8; }
.install-x {
  position: absolute; top: 0.8rem; left: 0.8rem; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: var(--bg-hover); color: var(--text); cursor: pointer; font-size: 1.2rem;
}
.install-card ol { list-style: none; margin: 0.9rem 0 0; padding: 0; display: grid; gap: 0.5rem; text-align: right; }
.install-card li {
  display: flex; gap: 0.7rem; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 0.65rem 0.75rem;
  color: var(--text); line-height: 1.7;
}
.install-card li b {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 0.8rem;
}
.install-card svg { width: 18px; height: 18px; vertical-align: -4px; }
.install-actions { display: grid; gap: 0.45rem; margin-top: 1rem; }
.install-actions .btn { width: 100%; }
@media (min-width: 720px) {
  .install-sheet { align-items: center; }
  .install-card { border-radius: 28px; }
}
.profile-card { max-width: 520px; }
.field-note { display: block; margin-top: 0.35rem; color: var(--text-muted); font-size: 0.78rem; }
.profile-card .form-control:disabled { opacity: 0.85; cursor: not-allowed; }

@media (max-width: 800px) {
  .sidebar {
    width: min(86vw, 320px);
    height: 100dvh;
    transform: translate3d(100%, 0, 0);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar.open { transform: translate3d(0, 0, 0); }
  .main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-right: 0;
    padding: calc(0.7rem + env(safe-area-inset-top)) 0.85rem calc(1.3rem + env(safe-area-inset-bottom));
  }
  #content, .card, .s-page, .s-block, .auth-card, .table-wrap { min-width: 0; max-width: 100%; }
  .topbar {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    grid-template-areas: "menu brand theme" "sub sub sub";
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .menu-btn { grid-area: menu; }
  .topbar-brand { grid-area: brand; min-width: 0; }
  .topbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .theme-btn { grid-area: theme; }
  .sub-chip.top {
    grid-area: sub;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.75rem;
  }
  .sub-chip.top span { display: inline; }
  .page-title, .s-head h1 { font-size: 1.28rem; }
  .card { padding: 0.95rem; }
  .stats { grid-template-columns: 1fr; }
  .stat { padding: 1rem; }
  .stat .value { font-size: 1.35rem; overflow-wrap: anywhere; }
  .form-control, .form-select, textarea { font-size: 16px; }
  .btn { min-height: 44px; }
  .steps { max-width: 100%; }
  .step { flex: 0 0 auto; min-width: 4.8rem; }
  .s-card, .s-block > header, .sub-banner, .s-save, .reval-hero { flex-direction: column; align-items: stretch; }
  .s-save .btn, .profile-card .btn, .wizard-actions .btn { width: 100%; margin-right: 0 !important; }
  .chip-add { flex-wrap: wrap; }
  .chip-add .form-control, .chip-add .form-select { max-width: 100%; min-width: 0; flex: 1 1 140px; }
  .reval-hero { padding: 1rem; }
  .reval-hero h2 { font-size: 1.22rem; }
  .auth-shell { min-height: 100dvh; align-items: start; padding: calc(1rem + env(safe-area-inset-top)) 0.9rem calc(1rem + env(safe-area-inset-bottom)); }
  .auth-card { padding: 1.05rem; }
  .modal-back { padding: 0.55rem; align-items: flex-end; }
  .edit-modal, .whatif-modal { width: 100%; max-height: 90dvh; border-radius: 18px 18px 12px 12px; }
  .jalali-popup { width: min(280px, calc(100vw - 16px)); }
  .install-sheet { padding: 0.55rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom)); }
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody { display: block; width: 100% !important; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.3rem 0.75rem 0.5rem;
    margin-bottom: 0.7rem;
    background: var(--bg);
  }
  .table-wrap td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.7rem;
    width: 100%;
    border: 0;
    padding: 0.42rem 0;
    text-align: left;
    overflow-wrap: anywhere;
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-align: right;
    flex: 0 0 auto;
  }
  .table-wrap td:not([data-label])::before,
  .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap .detail-row { padding: 0; margin: 0 0 0.75rem; border: 0; background: transparent; }
  .table-wrap .detail-row td { display: block; padding: 0; }
  .table-wrap .detail-row td::before { content: none; }
  td.trade-actions { flex-wrap: wrap; justify-content: stretch; }
  td.trade-actions::before { display: none; }
  td.trade-actions .btn { flex: 1 1 calc(50% - 0.3rem); }
}

