/* ============ EZAM Sales Intelligence — Design System ============ */
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn Static';
  src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn Static';
  src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #070B18;
  --bg-2: #0A102A;
  --surface: #0F1531;
  --surface-2: #151D42;
  --surface-3: #1B2452;
  --border: rgba(146, 160, 220, 0.13);
  --border-strong: rgba(146, 160, 220, 0.28);
  --text: #EAEDFB;
  --text-2: #A9B2d8;
  --text-3: #6B76A6;
  --brand: #252E6B;
  --accent: #7285F5;
  --accent-soft: rgba(114, 133, 245, 0.14);
  --gold: #E8B45A;
  --gold-soft: rgba(232, 180, 90, 0.13);
  --green: #2DD4A7;
  --green-soft: rgba(45, 212, 167, 0.12);
  --red: #F0647A;
  --red-soft: rgba(240, 100, 122, 0.12);
  --info: #5B8DEF;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 34px rgba(2, 5, 18, 0.55);
  --sidebar-w: 252px;
  font-size: 15px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Vazirmatn', 'Vazirmatn Static', 'Tahoma', sans-serif;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(52, 66, 158, 0.22), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(37, 46, 107, 0.25), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ---------- loading ---------- */
.loading-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--bg);
}
.loading-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.2px; }
.loading-sub { color: var(--text-2); font-size: 0.9rem; }
.loading-bar { width: 260px; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.loading-fill { height: 100%; width: 5%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .25s ease; }
.loading-msg { color: var(--text-3); font-size: 0.8rem; }

/* ---------- login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(52, 66, 158, 0.22), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(37, 46, 107, 0.25), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: linear-gradient(180deg, rgba(27, 36, 82, 0.34), rgba(15, 21, 49, 0.6)), var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px 28px;
}
.login-title { font-size: 1.05rem; font-weight: 800; text-align: center; margin-top: 14px; }
.login-sub { color: var(--text-3); font-size: 0.78rem; text-align: center; margin-top: 4px; margin-bottom: 22px; }
#loginForm { width: 100%; display: flex; flex-direction: column; }
.login-label { font-size: 0.76rem; color: var(--text-2); margin-bottom: 6px; }
.login-input {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 13px; font-family: inherit; font-size: 0.86rem;
  margin-bottom: 15px; transition: border-color .15s, box-shadow .15s;
}
.login-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error {
  color: var(--red); background: var(--red-soft); border: 1px solid rgba(240,100,122,.3);
  border-radius: 8px; padding: 8px 12px; font-size: 0.78rem; text-align: center; margin-bottom: 14px;
}
.login-btn { width: 100%; justify-content: center; padding: 11px; font-size: 0.88rem; margin-top: 2px; }
.logout-link {
  font-size: 0.72rem; color: var(--text-3); text-align: center; cursor: pointer;
  padding: 6px 4px 0; transition: color .15s;
}
.logout-link:hover { color: var(--red); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: 0; bottom: 0; right: 0;
  background: linear-gradient(180deg, rgba(21, 29, 66, .6), rgba(10, 16, 42, .3)) , var(--bg-2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px;
  overflow-y: auto;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 16px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; display: block; }
.loading-screen img, .login-card img { object-fit: contain; display: block; }
.brand-name { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.brand-sub { font-size: 0.7rem; color: var(--text-3); margin-top: 2px; }

.nav { flex: 1; margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.nav-group { font-size: 0.67rem; font-weight: 600; color: var(--text-3); letter-spacing: .4px; margin: 14px 10px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 0.86rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  border-color: rgba(114, 133, 245, 0.35);
  color: var(--text);
}
.nav-item .nico { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; opacity: .85; }
.nav-item .nico svg { width: 17px; height: 17px; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.asof-badge { font-size: 0.72rem; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.proto-badge { font-size: 0.65rem; color: var(--text-3); padding: 0 4px; }

.main { flex: 1; margin-right: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 26px;
  background: rgba(7, 11, 24, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1.12rem; font-weight: 700; }

.global-search { position: relative; }
.global-search input {
  width: 320px; max-width: 40vw;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 14px; font-family: inherit; font-size: 0.84rem;
  transition: border-color .15s, box-shadow .15s;
}
.global-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; left: 0;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; max-height: 340px; overflow-y: auto;
}
.search-item { padding: 9px 13px; font-size: 0.83rem; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.search-item:hover { background: var(--surface-3); }
.search-item .si-type { color: var(--text-3); font-size: 0.72rem; }

.content { padding: 24px 26px 60px; max-width: 1460px; width: 100%; margin: 0 auto; }

/* ---------- building blocks ---------- */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.3px; }
.page-head .sub { color: var(--text-2); font-size: 0.85rem; margin-top: 5px; line-height: 1.9; }

.grid { display: grid; gap: 14px; }
.grid > *, .two-col > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
@media (max-width: 1250px) { .g4, .g5, .g6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 980px) { .g2, .g3, .g4, .g5, .g6 { grid-template-columns: repeat(2, 1fr); } .span2, .span3 { grid-column: span 2; } }
@media (max-width: 660px) { .grid { grid-template-columns: 1fr !important; } .span2, .span3 { grid-column: span 1; } }

.card {
  background: linear-gradient(180deg, rgba(27, 36, 82, 0.34), rgba(15, 21, 49, 0.6)), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.card.hoverable:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.card-title { font-size: 0.92rem; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-sub { font-size: 0.76rem; color: var(--text-3); margin-bottom: 12px; line-height: 1.8; }

.kpi { position: relative; overflow: hidden; }
.kpi .kpi-label { font-size: 0.75rem; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .kpi-value { font-size: 1.42rem; font-weight: 800; margin-top: 7px; letter-spacing: -0.4px; }
.kpi .kpi-unit { font-size: 0.72rem; font-weight: 500; color: var(--text-3); margin-right: 4px; }
.kpi .kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.74rem; font-weight: 600; margin-top: 8px; padding: 3px 9px; border-radius: 999px; }
.kpi .kpi-note { font-size: 0.7rem; color: var(--text-3); margin-top: 8px; line-height: 1.7; }
.delta-up { color: var(--green); background: var(--green-soft); }
.delta-down { color: var(--red); background: var(--red-soft); }
.delta-flat { color: var(--text-2); background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid transparent; }
.badge.b-green { color: var(--green); background: var(--green-soft); border-color: rgba(45,212,167,.25); }
.badge.b-red { color: var(--red); background: var(--red-soft); border-color: rgba(240,100,122,.25); }
.badge.b-gold { color: var(--gold); background: var(--gold-soft); border-color: rgba(232,180,90,.25); }
.badge.b-blue { color: var(--accent); background: var(--accent-soft); border-color: rgba(114,133,245,.3); }
.badge.b-gray { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }

.insight {
  border-radius: var(--radius);
  border: 1px solid rgba(114, 133, 245, 0.3);
  background: linear-gradient(90deg, rgba(114,133,245,0.13), rgba(114,133,245,0.02));
  padding: 15px 18px; margin-bottom: 16px;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 0.88rem; line-height: 2;
}
.insight.warn { border-color: rgba(232,180,90,.35); background: linear-gradient(90deg, rgba(232,180,90,.12), rgba(232,180,90,.02)); }
.insight.danger { border-color: rgba(240,100,122,.35); background: linear-gradient(90deg, rgba(240,100,122,.12), rgba(240,100,122,.02)); }
.insight .ic { flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 1rem; }
.insight.warn .ic { background: var(--gold-soft); color: var(--gold); }
.insight.danger .ic { background: var(--red-soft); color: var(--red); }

.needs-data {
  border: 1px dashed rgba(232, 180, 90, 0.45);
  background: rgba(232, 180, 90, 0.05);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 0.82rem; line-height: 2;
}
.needs-data .nd-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--gold); font-weight: 700; font-size: 0.76rem; margin-bottom: 6px; }
.needs-data .nd-req { color: var(--text-2); }

/* ---------- charts ---------- */
.chart { width: 100%; min-height: 280px; }
.chart-tall { min-height: 360px; }
.chart-short { min-height: 210px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.tbl thead th {
  text-align: right; padding: 10px 13px; font-weight: 600; font-size: 0.74rem;
  color: var(--text-2); background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap; cursor: pointer; user-select: none;
  position: sticky; top: 0;
}
.tbl thead th.sorted { color: var(--accent); }
.tbl tbody td { padding: 9px 13px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl .num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.tbl-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.tbl-controls input, .tbl-controls select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font-family: inherit; font-size: 0.8rem;
}
.tbl-controls input:focus, .tbl-controls select:focus { outline: none; border-color: var(--accent); }
.tbl-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 0.75rem; color: var(--text-3); }
.pager { display: flex; gap: 6px; }
.pager button {
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 11px; cursor: pointer; font-family: inherit; font-size: 0.75rem;
}
.pager button:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.pager button:disabled { opacity: .35; cursor: default; }

/* ---------- controls ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select, .filters input, .seg-select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 13px; font-family: inherit; font-size: 0.82rem;
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--accent); }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font-size: 0.76rem; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: all .15s; font-family: inherit;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 9px 18px; font-family: inherit; font-size: 0.84rem; font-weight: 600;
  cursor: pointer; transition: filter .15s, transform .15s;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }

input[type="range"] { accent-color: var(--accent); }

/* ---------- misc ---------- */
.muted { color: var(--text-3); font-size: 0.78rem; }
.sep { height: 1px; background: var(--border); margin: 14px 0; }
.mono { font-variant-numeric: tabular-nums; direction: ltr; display: inline-block; }
.link { color: var(--accent); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; }
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }

.progress-track { height: 7px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), #9db1ff); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* copilot */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 480px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 2px 18px; }
.msg { max-width: 78%; border-radius: 16px; padding: 12px 17px; font-size: 0.87rem; line-height: 2.1; }
.msg.user { align-self: flex-start; background: var(--accent); color: #fff; border-bottom-left-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--border); border-bottom-right-radius: 5px; }
.msg.bot .evidence { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.chat-input { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px 16px; font-family: inherit; font-size: 0.88rem; }
.chat-input input:focus { outline: none; border-color: var(--accent); }

@media print {
  .sidebar, .topbar { display: none; }
  .main { margin: 0; }
  body { background: #fff; color: #000; }
}
