/* ============================================================
   Lyso CRM Multi-Tenant — Luxury Dark Glassmorphic UI (Phase 1)
   ============================================================ */
:root {
  --bg: #07080d;
  --bg-2: #0c0f18;
  --surface: rgba(17, 22, 35, 0.72);
  --surface-strong: rgba(20, 26, 42, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

body[data-accent="teal"]    { --accent: #2dd4bf; --accent-soft: rgba(45, 212, 191, 0.14); }
body[data-accent="steel"]   { --accent: #38bdf8; --accent-soft: rgba(56, 189, 248, 0.14); }
body[data-accent="emerald"] { --accent: #34d399; --accent-soft: rgba(52, 211, 153, 0.14); }
body[data-accent="amber"]   { --accent: #fbbf24; --accent-soft: rgba(251, 191, 36, 0.14); }
body[data-accent="copper"]  { --accent: #fb923c; --accent-soft: rgba(251, 146, 60, 0.14); }
body[data-accent="mono"]    { --accent: #e2e8f0; --accent-soft: rgba(226, 232, 240, 0.14); }

* { box-sizing: border-box; scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: radial-gradient(circle at 85% 10%, rgba(56, 189, 248, 0.08), transparent 40%),
              radial-gradient(circle at 10% 90%, rgba(99, 102, 241, 0.06), transparent 40%),
              var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; unicode-bidi: embed; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-md { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.glass-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---- Login ---- */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; overflow: hidden;
}
.login-orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.25; pointer-events: none;
}
.orb-1 { width: 340px; height: 340px; background: var(--accent); top: -80px; right: -80px; }
.orb-2 { width: 280px; height: 280px; background: #6366f1; bottom: -60px; left: -60px; }
.login-card { width: 100%; max-width: 410px; padding: 30px; position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 800; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(255,255,255,0.04));
  border: 1px solid var(--border-hi); color: var(--accent); overflow: hidden;
}
.brand-mark.sm { width: 38px; height: 38px; font-size: 16px; border-radius: 11px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.login-footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---- App Layout ---- */
.app-shell { display: flex; min-height: 100vh; width: 100%; }
.sidebar {
  width: 256px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: rgba(10, 13, 22, 0.9);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  padding: 18px 14px;
  z-index: 40;
  transition: transform 0.25s ease;
}
.sb-head { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; border-bottom: 1px solid var(--border); }
.sb-brand-info { min-width: 0; flex: 1; }
.sb-brand-info strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-info small { display: block; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 14px 0; }
.nav-item {
  width: 100%; border: 1px solid transparent; background: transparent; color: var(--muted);
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
  font-family: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: right;
  transition: all 0.16s ease;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: var(--accent-soft); border-color: rgba(255,255,255,0.1); color: var(--accent); font-weight: 700; }
.nav-ic { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sb-foot { padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sub-banner {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.18), rgba(248, 113, 113, 0.16));
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  padding: 9px 22px; font-size: 13px; color: #fde68a; text-align: center;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px;
  background: rgba(7, 8, 13, 0.78); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-right, .topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h2 { margin: 0; font-size: 17px; font-weight: 700; }
.view-container { padding: 22px 24px 48px; max-width: 1460px; width: 100%; margin: 0 auto; }

/* ---- Controls & Inputs ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  width: 100%; background: rgba(10, 14, 24, 0.85); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: inherit; font-size: 13.5px; outline: none;
  transition: border-color 0.15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 82px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.btn {
  border: 1px solid var(--border-hi); background: rgba(255,255,255,0.05); color: var(--text);
  padding: 9px 15px; border-radius: var(--radius-sm); font-family: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: all 0.16s ease; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); }
.btn-primary { background: var(--accent); color: #04070d; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-danger { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.35); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.25); }
.btn-danger-ghost { background: transparent; border-color: rgba(248,113,113,0.22); color: #fca5a5; }
.btn-danger-ghost:hover { background: rgba(248,113,113,0.12); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.04); color: var(--text); cursor: pointer;
  display: grid; place-items: center; font-size: 15px; flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }

/* ---- Badges, Grids, KPI Cards ---- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: rgba(255,255,255,0.06); border: 1px solid var(--border);
}
.pill.ok { color: var(--ok); background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.28); }
.pill.warn { color: var(--warn); background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.28); }
.pill.danger { color: var(--danger); background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.28); }
.pill.accent { color: var(--accent); background: var(--accent-soft); border-color: rgba(255,255,255,0.12); }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card-pad { padding: 18px 20px; }

.kpi-card { padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-val { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); }

/* ---- Tables ---- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td {
  padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; background: rgba(255,255,255,0.02); }
table.data-table tr:hover td { background: rgba(255,255,255,0.025); }

/* ---- Pipeline Kanban ---- */
.kanban-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.kanban-col { background: rgba(13, 17, 29, 0.72); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.deal-card {
  background: rgba(23, 30, 48, 0.85); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.deal-card:hover { border-color: var(--border-hi); }

/* ---- Progress & BI Bars ---- */
.bar-track { width: 100%; height: 9px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #818cf8); transition: width 0.35s ease; }

/* ---- Tabs Bar ---- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.subtab {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 9px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.subtab.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(255,255,255,0.14); }

/* ---- Modal & Toast ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px);
  z-index: 90; display: grid; place-items: center; padding: 16px; overflow-y: auto;
}
.modal-box { width: 100%; max-width: 720px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; background: var(--surface-strong); }
.modal-box.sm { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

.alert-err { padding: 10px 12px; border-radius: 10px; background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.35); color: #fecaca; font-size: 13px; }
.toast-stack { position: fixed; bottom: 20px; left: 20px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px; border-radius: 11px; background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-hi); color: var(--text); font-size: 13px; box-shadow: var(--shadow);
}
.toast.ok { border-color: rgba(52,211,153,0.45); color: #a7f3d0; }
.toast.err { border-color: rgba(248,113,113,0.45); color: #fecaca; }

.img-preview { max-height: 76px; max-width: 160px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,0.04); padding: 4px; }

/* ---- Mobile & Vertical Monitor Responsiveness ---- */
.mobile-only { display: none; }
.sb-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 35; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .mobile-only { display: inline-grid; }
  .sidebar { position: fixed; right: 0; top: 0; bottom: 0; transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .view-container { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
}

/* ---- Official A4 Print Engine ---- */
.print-area { display: none; }
@media print {
  body { background: #fff !important; color: #111 !important; }
  .login-shell, .app-shell, .modal-overlay, .toast-stack { display: none !important; }
  .print-area { display: block !important; padding: 10mm; color: #111; font-size: 12.5px; line-height: 1.75; }
  .a4-sheet { max-width: 190mm; margin: 0 auto; }
  .a4-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0f172a; padding-bottom: 10px; margin-bottom: 14px; }
  .a4-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
  .a4-table th, .a4-table td { border: 1px solid #cbd5e1; padding: 7px 9px; text-align: right; }
  .a4-table th { background: #f1f5f9; }
}
