:root {
  --brand: #1C9EC0;
  --brand-700: #08748F;
  --brand-900: #063D4E;
  --brand-050: #EAF8FB;
  --ink: #102F3A;
  --muted: #617A83;
  --line: #D9E8EC;
  --paper: #FFFFFF;
  --canvas: #F3F8FA;
  --green: #15966A;
  --green-soft: #E9F7F1;
  --red: #D95656;
  --amber: #E8A13A;
  --shadow: 0 18px 46px rgba(7, 69, 86, .09);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Vazirmatn, IRANSansX, "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.8;
}

button, input, select { font: inherit; }
.container { width: min(1240px, calc(100% - 34px)); margin-inline: auto; }
.hidden { display: none !important; }

.hero {
  position: relative;
  min-height: 510px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 10% 20%, rgba(112, 222, 247, .25), transparent 23rem),
    linear-gradient(125deg, #063D4E 0%, #08748F 54%, #1C9EC0 100%);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .11;
  background-image:
    linear-gradient(rgba(255,255,255,.8) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.8) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(90deg, #000 0%, transparent 72%);
}
.orb {
  position: absolute;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  pointer-events: none;
}
.orb.one { width: 390px; height: 390px; left: -135px; top: -190px; }
.orb.two { width: 240px; height: 240px; right: 8%; bottom: -165px; }
.orb.three { width: 84px; height: 84px; left: 26%; top: 28%; background: rgba(255,255,255,.035); }

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 28px;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 15px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(8px);
}
.brand-copy strong { display: block; font-size: .9rem; }
.brand-copy span { color: rgba(255,255,255,.65); font-size: .72rem; }

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.print-button, .ghost-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 12px;
  color: #fff;
  background: rgba(255,255,255,.09);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.print-button:hover, .ghost-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.16); }
.print-button:focus-visible, .ghost-button:focus-visible { outline: 3px solid rgba(255,255,255,.42); outline-offset: 2px; }

.hero-content {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
  gap: 54px;
  align-items: center;
  padding: 68px 0 105px;
}
.hero-kicker { display: flex; align-items: center; gap: 9px; color: #BDEFFA; font-size: .82rem; }
.hero-kicker::before { content: ""; width: 30px; height: 2px; border-radius: 99px; background: #72DCF3; }
h1 {
  max-width: 850px;
  margin: 10px 0 0;
  font-size: clamp(2rem, 4.25vw, 3.55rem);
  line-height: 1.42;
  letter-spacing: -.045em;
  font-weight: 850;
}
.hero-lead { max-width: 760px; margin: 16px 0 0; color: rgba(255,255,255,.76); font-size: .98rem; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 23px; }
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 999px;
  color: rgba(255,255,255,.86);
  background: rgba(5,55,69,.25);
  font-size: .78rem;
}
.hero-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #77E0F7; }

.hero-focus {
  position: relative;
  padding: 24px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 25px;
  background: rgba(3, 49, 62, .28);
  backdrop-filter: blur(10px);
}
.focus-label { color: rgba(255,255,255,.68); font-size: .78rem; }
.focus-value { margin-top: 3px; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.3; font-weight: 850; }
.focus-copy { margin-top: 4px; color: rgba(255,255,255,.74); font-size: .78rem; }
.focus-track { height: 7px; margin-top: 20px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.15); }
.focus-track span { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #BCEFFA, #fff); transition: width .4s ease; }

.filters {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}
.filters label { color: rgba(255,255,255,.72); font-size: .74rem; }
.filters-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.jalali-picker { display: flex; gap: 6px; }
.jalali-select {
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  color: #fff;
  background: rgba(255,255,255,.1);
}
.jalali-select option { color: var(--ink); background: #fff; }
.primary-button {
  appearance: none;
  min-height: 42px;
  padding: 8px 16px;
  border: 0;
  border-radius: 12px;
  color: var(--brand-900);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

main { position: relative; z-index: 3; margin-top: -62px; padding-bottom: 42px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.kpi, .panel {
  border: 1px solid rgba(202,222,228,.92);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.kpi { position: relative; min-height: 150px; padding: 20px; overflow: hidden; border-radius: 19px; }
.kpi::after { content: ""; position: absolute; width: 82px; height: 82px; left: -33px; bottom: -40px; border-radius: 50%; background: var(--brand-050); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .78rem; }
.kpi-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--brand-700); background: var(--brand-050); }
.kpi-value { margin-top: 13px; font-size: clamp(1.45rem,2.5vw,2.1rem); line-height: 1.35; letter-spacing: -.035em; font-weight: 850; }
.kpi-note { margin-top: 5px; color: var(--muted); font-size: .73rem; }

.panel { margin-bottom: 18px; padding: 24px; border-radius: var(--radius); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-label { color: var(--brand-700); font-size: .75rem; font-weight: 750; }
h2 { margin: 2px 0 0; font-size: 1.28rem; line-height: 1.5; letter-spacing: -.025em; }
.section-copy { margin: 4px 0 0; color: var(--muted); font-size: .79rem; }

.switcher { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #F7FBFC; }
.switch-button {
  appearance: none;
  border: 0;
  border-radius: 9px;
  padding: 7px 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: .76rem;
}
.switch-button[aria-pressed="true"] { color: #fff; background: var(--brand-700); }
.switch-button:focus-visible { outline: 3px solid rgba(28,158,192,.23); outline-offset: 2px; }

.analysis-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(300px,.65fr); gap: 18px; align-items: stretch; }
.analysis-grid > .panel { margin-bottom: 18px; }
.chart-wrap { position: relative; min-height: 340px; direction: ltr; }
#trendChart { display: block; width: 100%; height: 340px; overflow: visible; }
.chart-note { margin-top: 6px; color: var(--muted); text-align: center; font-size: .76rem; }
.tooltip {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 0;
  min-width: 160px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255,255,255,.97);
  box-shadow: 0 12px 28px rgba(9,69,84,.15);
  direction: rtl;
  font-size: .74rem;
  line-height: 1.75;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%,-105%);
}
.tooltip.show { opacity: 1; visibility: visible; }

.health { display: flex; flex-direction: column; }
.ring-area { display: grid; place-items: center; padding: 7px 0 18px; }
.ring {
  --v: 0;
  position: relative;
  width: 158px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--brand) calc(var(--v)*1%), #E7EEF0 0);
}
.ring::after { content: ""; position: absolute; inset: 15px; border-radius: 50%; background: #fff; }
.ring-inner { position: relative; z-index: 1; text-align: center; }
.ring-inner strong { display: block; font-size: 1.75rem; line-height: 1.25; }
.ring-inner span { color: var(--muted); font-size: .72rem; }
.health-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.health-row span { color: var(--muted); font-size: .77rem; }
.health-row strong { font-size: .9rem; }
.health-row .ok { color: var(--green); }
.token-mix { margin-top: auto; padding-top: 15px; }
.token-labels { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--muted); font-size: .72rem; }
.token-bar { display: flex; height: 12px; overflow: hidden; border-radius: 999px; background: #E8F0F2; }
.token-bar .input { background: var(--brand); }
.token-bar .output { min-width: 0; background: var(--amber); }

.leaders { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 18px; }
.leader-card { position: relative; overflow: hidden; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg,#fff,#F5FBFC); }
.leader-card::after { content: ""; position: absolute; width: 120px; height: 120px; left: -48px; bottom: -62px; border-radius: 50%; background: rgba(28,158,192,.08); }
.leader-label { color: var(--brand-700); font-size: .75rem; font-weight: 750; }
.leader-name { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: left; font-size: 1rem; font-weight: 800; }
.leader-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 17px; }
.leader-metric span { display: block; color: var(--muted); font-size: .68rem; }
.leader-metric strong { display: block; margin-top: 1px; font-size: .88rem; }

.ranking { display: grid; gap: 14px; }
.rank-item { display: grid; gap: 7px; }
.rank-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .78rem; }
.rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: left; }
.rank-value { flex: 0 0 auto; color: var(--brand-700); font-weight: 800; }
.track { height: 8px; overflow: hidden; border-radius: 999px; background: #E7F0F3; }
.fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--brand-700),#47BCD7); transition: width .38s ease; }

.insights { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.insight { position: relative; min-height: 178px; padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: #FBFDFE; }
.insight-num { width: 27px; height: 27px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 8px; color: var(--brand-700); background: var(--brand-050); font-size: .72rem; font-weight: 800; }
.insight strong { display: block; margin-bottom: 5px; font-size: .86rem; }
.insight p { margin: 0; color: var(--muted); font-size: .74rem; }

.table-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-input {
  min-height: 40px;
  min-width: min(280px, 100%);
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #F7FBFC;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: right; font-size: .76rem; }
th { color: var(--muted); background: #F7FAFB; white-space: nowrap; font-weight: 750; }
tbody tr:hover { background: #F8FCFD; }
tbody tr:last-child td { border-bottom: 0; }
td.num { direction: ltr; font-variant-numeric: tabular-nums; }
.key-name { display: block; max-width: 270px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: left; }
.key-name.clickable, .rank-name.clickable { cursor: pointer; color: var(--brand-700); font-weight: 800; }
.key-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 360px; }
.key-chip {
  appearance: none;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand-700);
  background: var(--brand-050);
  cursor: pointer;
  direction: ltr;
  font-size: .72rem;
  font-weight: 800;
}
.key-chip:hover { background: #dff3f8; }
.rate-high { color: var(--green); font-weight: 750; }
.rate-low { color: var(--red); font-weight: 750; }
.linkish {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--brand-700);
  cursor: pointer;
  font-weight: 800;
  padding: 0;
}

.report-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 4px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--brand-050); color: #42636D; font-size: .73rem; }
footer { padding: 5px 0 30px; color: var(--muted); text-align: center; font-size: .72rem; }
.warn { color: #9a5b12; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(circle at 10% 20%, rgba(112, 222, 247, .25), transparent 23rem),
    linear-gradient(125deg, #063D4E 0%, #08748F 54%, #1C9EC0 100%);
}
.login-card {
  width: min(460px, 100%);
  padding: 32px 28px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 28px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.6rem; letter-spacing: -.03em; }
.login-card p { color: var(--muted); margin: 8px 0 22px; font-size: .86rem; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { color: var(--brand-700); font-size: .78rem; font-weight: 750; }
.field input {
  min-height: 46px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #F7FBFC;
}
.login-card .primary-button { width: 100%; margin-top: 8px; background: var(--brand-700); color: #fff; }
.login-error { min-height: 24px; color: var(--red); font-size: .8rem; }

.loading-veil {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(243,248,250,.72);
  backdrop-filter: blur(4px);
}
.loading-box {
  padding: 18px 22px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--brand-900);
  font-weight: 800;
}

.modal-veil {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(6, 61, 78, .42);
}
.modal {
  width: min(860px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;
  padding: 22px;
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }

.enter { animation: enter .5s ease both; }
.enter:nth-child(2) { animation-delay: .05s; }
.enter:nth-child(3) { animation-delay: .10s; }
.enter:nth-child(4) { animation-delay: .15s; }
@keyframes enter { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1000px) {
  .hero-content { grid-template-columns: 1fr; gap: 25px; padding-top: 52px; }
  .hero-focus { max-width: 520px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .analysis-grid { grid-template-columns: 1fr; }
  .insights { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 700px) {
  .container { width: min(100% - 20px,1240px); }
  .hero { min-height: 0; }
  .topbar { padding-top: 20px; }
  .brand-copy span { display: none; }
  .hero-content { padding: 46px 0 98px; }
  .hero-lead { font-size: .88rem; }
  main { margin-top: -54px; }
  .kpi-grid { gap: 9px; }
  .kpi { min-height: 142px; padding: 16px; }
  .panel { padding: 18px 14px; border-radius: 18px; }
  .panel-head { flex-direction: column; }
  .switcher { width: 100%; }
  .switch-button { flex: 1 1 auto; }
  .chart-wrap,#trendChart { min-height: 300px; height: 300px; }
  .leaders { grid-template-columns: 1fr; }
  .insights { grid-template-columns: 1fr; }
  .insight { min-height: 0; }
  .report-foot { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 450px) {
  .brand-copy strong { display: none; }
  .print-button span, .ghost-button span { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .hero-tags { display: grid; }
  .leader-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,*::before,*::after { animation: none !important; transition: none !important; }
}
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  body { background: #fff; }
  .hero { min-height: 0; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .hero-content { padding: 35px 0 78px; }
  .hero-focus, .print-button, .ghost-button, .filters, .search-input, .loading-veil, .modal-veil { display: none !important; }
  .container { width: 100%; }
  .kpi,.panel { box-shadow: none; break-inside: avoid; }
  .panel { padding: 16px; }
  .switcher { display: none; }
  .analysis-grid { grid-template-columns: 1.55fr .65fr; }
  .insights { grid-template-columns: repeat(4,1fr); }
}
