:root {
  --bg: #08090f;
  --surface: #11131e;
  --card: #171a29;
  --card-elevated: #1e2235;
  --border: rgba(148, 163, 184, 0.16);
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --accent: #a78bfa;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Vazirmatn", Tahoma, sans-serif;
  background: radial-gradient(circle at top right, rgba(124, 58, 237, 0.16), transparent 45%),
              radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 40%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.muted {
  color: var(--muted);
}

.sm-text {
  font-size: 0.85rem;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-footer {
  display: flex;
  justify-content: center;
}

.brand-lockup, .topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
}

h2 {
  font-size: 1.05rem;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 12px;
  padding: 0.65rem 1.15rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.15s ease;
}

.tab.active {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent);
  color: var(--text);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.tab-panel.active {
  display: flex;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem;
}

.kpi strong {
  display: block;
  font-size: 1.55rem;
  margin-top: 0.35rem;
  color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }

@media (max-width: 780px) {
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-4 { grid-column: span 2; }
}

@media (max-width: 540px) {
  .form-grid, .form-grid-4 { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: span 1; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

input, select, textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.62rem 0.8rem;
  font-size: 0.9rem;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0.62rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn.sm {
  padding: 0.42rem 0.75rem;
  font-size: 0.8rem;
}

.btn.full {
  width: 100%;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.ghost {
  background: var(--card-elevated);
  border-color: var(--border);
  color: var(--text);
}

.btn.danger-soft {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.pill.ok { background: rgba(16, 185, 129, 0.16); color: #6ee7b7; }
.pill.warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }
.pill.danger { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.pill.proto { background: rgba(124, 58, 237, 0.22); color: var(--accent); }

.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.55rem 0.8rem;
  overflow-x: auto;
}

.copy-row code {
  font-size: 0.82rem;
  color: var(--accent);
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.search-input {
  max-width: 280px;
}

.item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.item-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 210px;
  flex: 1;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #06b6d4);
  border-radius: 999px;
}

.alert-box {
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-size: 0.86rem;
}

.alert-box.warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.alert-box.danger {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 11, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-elevated);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 80;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
