@font-face {
  font-family: "IRANSans";
  font-style: normal;
  font-weight: 400;
  src: url("/fonts/IRANSansWeb(FaNum).woff2") format("woff2");
}

@font-face {
  font-family: "IRANSans";
  font-style: normal;
  font-weight: 700;
  src: url("/fonts/IRANSansWeb(FaNum)_Bold.woff2") format("woff2");
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: IRANSans, Tahoma, Arial, sans-serif;
  color: #25283a;
  background: #f1f2f5;
}

body[data-theme="dark"] {
  color: #e8eaf0;
  background: #12151f;
}

.auth-shell,
.admin-shell {
  min-height: 100vh;
  padding: 36px 20px;
}

.auth-shell {
  display: grid;
  place-items: center;
}

.auth-card,
.panel {
  background: #fff;
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(30, 35, 60, 0.1);
}

body[data-theme="dark"] .auth-card,
body[data-theme="dark"] .panel {
  background: #1b2030;
  border-color: #2c3448;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.auth-card {
  width: min(430px, 100%);
  padding: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8f96ad;
  direction: ltr;
  font-size: 12px;
  text-align: right;
}

h1 {
  margin: 0 0 24px;
  color: #1f2476;
  font-size: 24px;
}

body[data-theme="dark"] h1 {
  color: #8dbdff;
}

label {
  display: block;
  margin-bottom: 14px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #626878;
  font-size: 13px;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid #e4e7ee;
  border-radius: 4px;
  padding: 0 12px;
  direction: ltr;
  font: inherit;
}

body[data-theme="dark"] input {
  border-color: #354057;
  background: #121722;
  color: #f3f6fb;
}

button {
  height: 40px;
  border: 0;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.download-button {
  min-width: 104px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d5e6ff;
  border-radius: 4px;
  background: #f7fbff;
  color: #246db5;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.auth-card button,
.refresh-button {
  min-width: 120px;
  background: #4da3ff;
  color: #fff;
}

.auth-card button {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  display: none;
  margin: 16px 0 0;
  color: #ff1656;
  text-align: center;
  font-size: 13px;
}

.login-error.is-visible {
  display: block;
}

.panel {
  width: min(1040px, 100%);
  margin: 0 auto;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px;
  border-bottom: 1px solid #eef0f5;
}

.panel-header h1 {
  margin-bottom: 0;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-button {
  min-width: 86px;
  border: 1px solid #e4e7ee;
  background: #fff;
  color: #626878;
}

.reset-button {
  min-width: 110px;
  border: 1px solid #ffb7c9;
  background: #fff;
  color: #ff1656;
}

body[data-role="read_only"] .owner-only {
  display: none !important;
}

.theme-button {
  min-width: 96px;
  border: 1px solid #e4e7ee;
  background: #fff;
  color: #626878;
}

body[data-theme="dark"] .theme-button,
body[data-theme="dark"] .download-button,
body[data-theme="dark"] .reset-button,
body[data-theme="dark"] .logout-button {
  border-color: #354057;
  background: #121722;
  color: #d6dbe7;
}

body[data-theme="dark"] .reset-button {
  border-color: #7a3449;
  color: #ff8ead;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: #eef0f5;
}

body[data-theme="dark"] .stats {
  background: #2c3448;
}

.stats div {
  padding: 18px 30px;
  background: #fafbfc;
}

body[data-theme="dark"] .stats div {
  background: #171c29;
}

.stats span {
  display: block;
  margin-bottom: 8px;
  color: #8b909f;
  font-size: 12px;
}

.stats strong {
  color: #303447;
  font-size: 18px;
}

body[data-theme="dark"] .stats strong,
body[data-theme="dark"] td {
  color: #e8eaf0;
}

.analytics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: #eef0f5;
  border-top: 1px solid #eef0f5;
}

.metric-card {
  padding: 18px 30px;
  background: #fff;
}

.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: #8b909f;
  font-size: 12px;
}

.metric-card strong {
  color: #1f2476;
  font-size: 22px;
}

.chart-panel {
  padding: 22px 30px 26px;
  border-top: 1px solid #eef0f5;
}

.chart-row {
  display: grid;
  grid-template-columns: 115px 1fr 54px;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  color: #626878;
  font-size: 13px;
}

.chart-row:last-child {
  margin-bottom: 0;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #4da3ff;
  transition: width 0.35s ease;
}

.bar.secondary {
  background: #20c997;
}

.bar.danger {
  background: #ff5c8a;
}

body[data-theme="dark"] .analytics,
body[data-theme="dark"] .chart-panel {
  background: #1b2030;
  border-color: #2c3448;
}

body[data-theme="dark"] .analytics {
  background: #2c3448;
}

body[data-theme="dark"] .metric-card {
  background: #171c29;
}

body[data-theme="dark"] .metric-card strong {
  color: #8dbdff;
}

body[data-theme="dark"] .bar-track {
  background: #283145;
}

.table-wrap {
  overflow-x: auto;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 30px 6px;
  border-top: 1px solid #eef0f5;
  background: #fff;
}

.log-search {
  max-width: 360px;
  height: 36px;
  background: #f8f9fb;
}

body[data-theme="dark"] .log-search {
  background: #121722;
}

.mask-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: #8f96a5;
  font-size: 11px;
  opacity: 0.45;
  transition: opacity 160ms ease, color 160ms ease;
  cursor: pointer;
}

.mask-toggle:hover {
  color: #626878;
  opacity: 0.9;
}

.mask-toggle input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: #4da3ff;
}

.mask-toggle span {
  margin: 0;
}

body[data-theme="dark"] .table-toolbar {
  border-color: #2c3448;
  background: #1b2030;
}

body[data-theme="dark"] .mask-toggle {
  color: #aeb7c9;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid #eef0f5;
  text-align: right;
  white-space: nowrap;
}

body[data-theme="dark"] th,
body[data-theme="dark"] td {
  border-color: #2c3448;
}

th {
  color: #626878;
  background: #f8f9fb;
  font-size: 13px;
  font-weight: 700;
}

body[data-theme="dark"] th {
  color: #aeb7c9;
  background: #171c29;
}

td {
  color: #303447;
  font-size: 14px;
}

tbody tr:hover td {
  background: #f8fbff;
}

body[data-theme="dark"] tbody tr:hover td {
  background: #20283a;
}

.empty {
  padding: 38px 18px;
  color: #8b909f;
  text-align: center;
}

.error {
  color: #ff1656;
}

.reports-panel {
  width: min(1440px, 100%);
}

.report-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 30px;
  border-bottom: 1px solid #eef0f5;
  background: #fbfcff;
}

body[data-theme="dark"] .report-tabs {
  border-color: #2c3448;
  background: #171c29;
}

.tab-button {
  min-width: max-content;
  padding: 0 14px;
  border: 1px solid #e4e7ee;
  background: #fff;
  color: #626878;
  font-size: 13px;
}

.tab-button.is-active {
  border-color: #4da3ff;
  background: #4da3ff;
  color: #fff;
}

body[data-theme="dark"] .tab-button {
  border-color: #354057;
  background: #121722;
  color: #d6dbe7;
}

body[data-theme="dark"] .tab-button.is-active {
  border-color: #4da3ff;
  background: #246db5;
  color: #fff;
}

.report-view {
  display: none;
  padding: 24px 30px 32px;
}

.report-view.is-active {
  display: block;
}

.bi-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.bi-kpis article,
.bi-card {
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  background: #fff;
}

body[data-theme="dark"] .bi-kpis article,
body[data-theme="dark"] .bi-card {
  border-color: #2c3448;
  background: #171c29;
}

.bi-kpis article {
  padding: 18px;
}

.bi-kpis span {
  display: block;
  margin-bottom: 10px;
  color: #8b909f;
  font-size: 12px;
}

.bi-kpis strong {
  color: #1f2476;
  font-size: 26px;
}

body[data-theme="dark"] .bi-kpis strong {
  color: #8dbdff;
}

.bi-alert {
  margin: 0 0 18px;
  padding: 16px 20px;
  border: 1px solid #ff6b7d;
  border-radius: 8px;
  background: #fff1f3;
  color: #e10023;
  font-weight: 700;
  line-height: 2;
}

.bi-alert strong,
.bi-alert b {
  color: #c7001d;
}

body[data-theme="dark"] .bi-alert {
  border-color: #7f1d2d;
  background: #2a1119;
  color: #ff8fa0;
}

body[data-theme="dark"] .bi-alert strong,
body[data-theme="dark"] .bi-alert b {
  color: #ffb0bd;
}

.bi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.funnel-card {
  margin-bottom: 18px;
}

.funnel-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid #eef0f5;
}

.funnel-stats article {
  min-height: 86px;
  padding: 18px 22px;
  border-left: 1px solid #eef0f5;
  border-bottom: 1px solid #eef0f5;
}

.funnel-stats article:nth-child(4n),
.funnel-stats article:last-child {
  border-left: 0;
}

.funnel-stats article.wide {
  grid-column: auto;
}

.funnel-stats span {
  display: block;
  margin-bottom: 8px;
  color: #8b909f;
  font-size: 13px;
}

.funnel-stats strong {
  color: #4da3ff;
  font-size: 24px;
}

.funnel-bars {
  padding: 22px 28px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 120px 1fr 70px;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.funnel-row:last-child {
  margin-bottom: 0;
}

.funnel-row span,
.funnel-row em {
  color: #8b909f;
  font-style: normal;
  font-size: 13px;
}

.funnel-row i {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.funnel-row b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #4da3ff;
  transition: width 0.35s ease;
}

.funnel-row b.success {
  background: #20c997;
}

.funnel-row b.pink {
  background: #ff5c8a;
}

body[data-theme="dark"] .funnel-stats,
body[data-theme="dark"] .funnel-stats article {
  border-color: #2c3448;
}

body[data-theme="dark"] .funnel-row i {
  background: #283145;
}

.bi-card {
  overflow: hidden;
  margin-bottom: 16px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: center;
  gap: 18px;
  padding: 4px 20px 12px;
}

.donut {
  width: 158px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  background: #edf1f7;
}

.donut.large {
  width: 176px;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 25px;
  border-radius: inherit;
  background: #fff;
}

body[data-theme="dark"] .donut::after {
  background: #171c29;
}

.donut span {
  position: relative;
  z-index: 1;
  display: grid;
  max-width: 86px;
  color: #1f2476;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.donut span strong {
  color: inherit;
  font-size: 28px;
  line-height: 1;
}

body[data-theme="dark"] .donut span {
  color: #8dbdff;
}

.donut small {
  margin-top: 7px;
  color: #8b909f;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.donut-legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.legend-item {
  height: auto;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid #e8eaf0;
  border-radius: 8px;
  background: #f8fbff;
  color: #626878;
  font-size: 12px;
  font-weight: 400;
  text-align: right;
}

.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-item b {
  min-width: 54px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eaf3ff;
  color: #1f2476;
  font-weight: 800;
  text-align: center;
}

.legend-item em {
  min-width: 48px;
  color: #626878;
  font-style: normal;
  font-weight: 700;
  text-align: left;
}

body[data-theme="dark"] .legend-item,
body[data-theme="dark"] .legend-item b,
body[data-theme="dark"] .legend-item em {
  color: #d6dbe7;
}

body[data-theme="dark"] .legend-item {
  border-color: #2c3448;
  background: #121722;
}

body[data-theme="dark"] .legend-item b {
  background: #22314a;
  color: #8dbdff;
}

.bi-card header {
  padding: 18px 20px 8px;
}

.bi-card h2 {
  margin: 0;
  color: #1f2476;
  font-size: 17px;
}

.bi-card p {
  margin: 8px 0 0;
  color: #8b909f;
  font-size: 12px;
}

body[data-theme="dark"] .bi-card h2 {
  color: #8dbdff;
}

.rank-chart {
  padding: 12px 20px 20px;
}

.rank-row {
  width: 100%;
  height: auto;
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr 52px 54px;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 400;
  text-align: right;
}

.interactive .rank-row:hover {
  background: #f8fbff;
}

body[data-theme="dark"] .interactive .rank-row:hover {
  background: #20283a;
}

.rank-label {
  overflow: hidden;
  color: #303447;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-theme="dark"] .rank-label {
  color: #e8eaf0;
}

.rank-bar {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}

.rank-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #4da3ff;
}

body[data-theme="dark"] .rank-bar {
  background: #283145;
}

.rank-row b,
.rank-row em {
  color: #626878;
  font-style: normal;
  font-size: 12px;
}

.detail-card {
  margin-top: 14px;
}

.report-search {
  width: calc(100% - 40px);
  margin: 0 20px 14px;
  direction: rtl;
  text-align: right;
}

.report-table table {
  min-width: 980px;
}

.report-table td small {
  display: block;
  margin-top: 4px;
  color: #8b909f;
  direction: ltr;
  font-size: 11px;
  text-align: right;
}

@media (max-width: 640px) {
  .auth-shell,
  .admin-shell {
    padding: 18px 12px;
  }

  .auth-card {
    padding: 26px 20px;
  }

  .panel-header,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .analytics {
    grid-template-columns: 1fr;
  }

  .bi-kpis,
  .bi-grid,
  .funnel-stats {
    grid-template-columns: 1fr;
  }

  .donut-wrap,
  .donut-legend {
    grid-template-columns: 1fr;
  }

  .donut {
    margin: 0 auto;
  }

  .funnel-stats article {
    grid-column: auto !important;
    border-left: 0;
    border-bottom: 1px solid #eef0f5;
  }

  .funnel-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .report-view,
  .report-tabs {
    padding-right: 14px;
    padding-left: 14px;
  }

  .rank-row {
    grid-template-columns: 1fr;
  }

  .chart-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
