:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-strong: #0b0b0d;
  --surface-muted: #efefec;
  --text: #101012;
  --text-muted: #68686f;
  --text-on-dark: #ffffff;
  --border: #dcdcd8;
  --border-strong: #b9b9b3;
  --red: #d10b05;
  --red-soft: #fff0ef;
  --green: #137a4b;
  --warning: #8b5200;
  --warning-bg: #fff6d9;
  --shadow: 0 20px 60px rgba(15, 15, 18, 0.08);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 32px;
  --font:
    'IBM Plex Sans Arabic', 'DIN Next Arabic', 'Segoe UI', Tahoma, sans-serif;
  --font-data: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #08080a;
  --surface: #121214;
  --surface-strong: #f6f6f4;
  --surface-muted: #1d1d20;
  --text: #f7f7f5;
  --text-muted: #a7a7ae;
  --text-on-dark: #09090b;
  --border: #2f2f33;
  --border-strong: #4b4b51;
  --red: #ff3c35;
  --red-soft: #321110;
  --green: #52d196;
  --warning: #ffd16e;
  --warning-bg: #302410;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'] {
    --bg: #08080a;
    --surface: #121214;
    --surface-strong: #f6f6f4;
    --surface-muted: #1d1d20;
    --text: #f7f7f5;
    --text-muted: #a7a7ae;
    --text-on-dark: #09090b;
    --border: #2f2f33;
    --border-strong: #4b4b51;
    --red: #ff3c35;
    --red-soft: #321110;
    --green: #52d196;
    --warning: #ffd16e;
    --warning-bg: #302410;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: fixed;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  z-index: 1000;
  translate: 0 -180%;
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text-on-dark);
  padding: 10px 16px;
  text-decoration: none;
}

.skip-link:focus {
  translate: 0;
}

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.eyebrow,
.section-index {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 14%, transparent);
}

.icon-button {
  display: inline-flex;
  min-width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.icon-button:active {
  background: var(--border);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.icon-button span {
  font-family: var(--font-data);
  font-size: 0.76rem;
  font-weight: 700;
}

.danger-hover:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Login */

.login-page {
  position: relative;
  overflow-x: hidden;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
}

.login-page::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 10%, var(--red-soft), transparent 34%),
    var(--bg);
  content: '';
  opacity: 0.94;
}

.login-toolbar {
  position: fixed;
  inset-block-start: 24px;
  inset-inline-end: 24px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.login-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.75fr);
}

.login-story,
.login-panel {
  padding: clamp(40px, 6vw, 96px);
}

.login-story {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: space-between;
  border-inline-end: 1px solid var(--border);
}

.story-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.story-brand img,
.sidebar-brand img {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.story-brand strong,
.sidebar-brand strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.15;
}

.story-brand span,
.sidebar-brand small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.story-copy {
  max-width: 780px;
  padding-block: 80px;
}

.story-copy h1 {
  max-width: 15ch;
  margin: 0;
  font-size: clamp(2.7rem, 5.5vw, 6.5rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.02;
}

[dir='rtl'] .story-copy h1 {
  letter-spacing: -0.025em;
}

.story-copy > p:last-child {
  max-width: 62ch;
  margin: 28px 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.9;
}

.privacy-list {
  display: grid;
  margin: 0;
  padding: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
}

.privacy-list li {
  display: flex;
  min-width: 0;
  gap: 12px;
  border-block-start: 1px solid var(--border);
  padding: 18px 12px 0;
}

.privacy-list li + li {
  border-inline-start: 1px solid var(--border);
}

.privacy-list > li > span {
  color: var(--red);
  font-family: var(--font-data);
  font-size: 0.74rem;
  font-weight: 700;
}

.privacy-list p {
  min-width: 0;
  margin: 0;
}

.privacy-list strong,
.privacy-list small {
  display: block;
}

.privacy-list strong {
  font-size: 0.9rem;
}

.privacy-list small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.login-panel {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
  background: var(--surface);
}

.panel-number {
  position: absolute;
  inset-block-start: 32px;
  inset-inline-start: clamp(40px, 6vw, 96px);
  color: var(--red);
  font-family: var(--font-data);
  font-size: 0.76rem;
  font-weight: 700;
}

.panel-heading {
  margin-bottom: 32px;
}

.panel-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.panel-heading > p:last-child {
  margin: 12px 0 0;
  color: var(--text-muted);
}

.field + .field {
  margin-top: 20px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.86rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 12px 15px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.field input:hover {
  border-color: var(--text-muted);
}

.field input:focus {
  border-color: var(--red);
  outline: 0;
  box-shadow: 0 0 0 4px var(--red-soft);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-inline-end: 78px;
}

.text-button {
  position: absolute;
  inset-block: 6px;
  inset-inline-end: 6px;
  min-width: 62px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.text-button:hover {
  background: var(--red-soft);
}

.form-error {
  min-height: 25px;
  margin: 12px 0;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 650;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  color: var(--text-on-dark);
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 800;
  transition:
    background-color 180ms ease,
    opacity 180ms ease,
    translate 180ms ease;
}

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

.primary-button:active {
  translate: 0 1px;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.primary-button svg {
  width: 22px;
  height: 22px;
}

[dir='rtl'] .primary-button svg {
  rotate: 0deg;
}

[dir='rtl'] .primary-button svg.directional-icon {
  rotate: 180deg;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 28px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.security-note svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
}

/* Dashboard */

.dashboard-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  inset-block-start: 0;
  display: flex;
  height: 100dvh;
  flex-direction: column;
  background: #09090b;
  color: #fff;
  padding: 28px 20px;
}

.sidebar-brand {
  padding: 0 8px 28px;
  border-block-end: 1px solid #2a2a2e;
}

.sidebar-brand img {
  border-radius: 16px;
}

.sidebar-brand small {
  color: #92929a;
}

.sidebar-nav {
  display: grid;
  gap: 7px;
  margin-top: 30px;
}

.nav-item {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: #a9a9b0;
  padding: 10px 13px;
  text-decoration: none;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item:hover {
  border-color: #2f2f34;
  background: #151518;
  color: #fff;
}

.nav-item.active {
  background: #fff;
  color: #09090b;
  font-weight: 800;
}

.sidebar-foot {
  margin-top: auto;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid #2f2f34;
  border-radius: 14px;
  background: #121214;
  padding: 13px;
}

.privacy-badge svg {
  width: 23px;
  height: 23px;
  color: #ff443e;
}

.privacy-badge span,
.privacy-badge strong,
.privacy-badge small {
  display: block;
}

.privacy-badge strong {
  font-size: 0.76rem;
}

.privacy-badge small {
  color: #92929a;
  font-size: 0.68rem;
}

.dashboard-main {
  width: min(100%, 1640px);
  min-width: 0;
  margin-inline: auto;
  padding: 32px clamp(20px, 4vw, 64px) 24px;
}

.dashboard-header,
.section-bar,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.dashboard-header {
  margin-bottom: 54px;
}

.dashboard-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  letter-spacing: -0.05em;
  line-height: 1.05;
}

[dir='rtl'] .dashboard-header h1 {
  letter-spacing: -0.025em;
}

.header-subtitle {
  margin: 9px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.section-bar {
  align-items: flex-end;
  margin-bottom: 20px;
}

.section-index {
  color: var(--red);
}

.section-bar h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.25rem);
  letter-spacing: -0.035em;
}

.range-control {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px;
}

.range-control button {
  min-width: 76px;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  transition:
    background-color 180ms ease,
    color 180ms ease;
}

.range-control button:hover {
  color: var(--text);
}

.range-control button.active {
  background: var(--surface-strong);
  color: var(--text-on-dark);
}

.error-banner,
.warning-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  padding: 14px 16px;
}

.error-banner {
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--border));
  background: var(--red-soft);
  color: var(--text);
}

.error-banner strong,
.error-banner span {
  display: block;
}

.error-banner span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.error-banner button,
.warning-banner button {
  min-height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text-on-dark);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 750;
}

.warning-banner {
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.86rem;
  font-weight: 650;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  position: relative;
  min-width: 0;
  min-height: 162px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}

.kpi-card::after {
  position: absolute;
  inset-block-end: -22px;
  inset-inline-end: -22px;
  width: 62px;
  height: 62px;
  border: 1px solid var(--border);
  border-radius: 999px;
  content: '';
}

.primary-kpi {
  border-color: #09090b;
  background: #09090b;
  color: #fff;
}

.primary-kpi::after {
  border-color: #ff3c35;
}

.primary-kpi .kpi-label,
.primary-kpi small {
  color: #aaaab1;
}

.kpi-label {
  display: block;
  min-height: 44px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.kpi-card strong {
  display: block;
  overflow: hidden;
  margin-top: 10px;
  font-family: var(--font-data);
  font-size: clamp(1.55rem, 2.4vw, 2.35rem);
  letter-spacing: -0.055em;
  line-height: 1;
  text-overflow: ellipsis;
}

.kpi-card small {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
  margin-top: 13px;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.kpi-card small.positive {
  color: var(--green);
}

.kpi-card small.negative {
  color: var(--red);
}

.live-kpi .signal-dot {
  width: 6px;
  height: 6px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: clamp(18px, 2.5vw, 30px);
  box-shadow: var(--shadow);
}

.trend-panel {
  margin-top: 12px;
  box-shadow: none;
}

.panel-title {
  align-items: flex-start;
  margin-bottom: 22px;
}

.panel-title h3 {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.025em;
}

.panel-title .eyebrow {
  margin-bottom: 3px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--text-muted);
  font-size: 0.73rem;
}

.chart-legend > span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-line {
  display: inline-block;
  width: 22px;
  border-block-start: 2px solid var(--red);
}

.legend-line.dashed {
  border-block-start-color: var(--text-muted);
  border-block-start-style: dashed;
}

.chart-wrap {
  min-height: 280px;
  overflow: hidden;
  border-block: 1px solid var(--border);
  padding-block: 18px 8px;
}

.trend-svg {
  width: 100%;
  height: 260px;
  overflow: visible;
}

.trend-svg .grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.trend-svg .axis-label {
  fill: var(--text-muted);
  stroke: none;
  font-family: var(--font-data);
  font-size: 11px;
}

.trend-svg .pageviews-line,
.trend-svg .visitors-line {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-width: 3;
}

.trend-svg .pageviews-line {
  stroke: var(--red);
}

.trend-svg .visitors-line {
  stroke: var(--text-muted);
  stroke-dasharray: 7 7;
  stroke-width: 2;
}

.trend-svg .pageviews-area {
  fill: var(--red-soft);
  stroke: none;
}

.chart-empty {
  display: grid;
  min-height: 260px;
  place-items: center;
  color: var(--text-muted);
  text-align: center;
}

.data-table-details {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.data-table-details summary {
  width: fit-content;
  min-height: 44px;
  padding-block: 10px;
  cursor: pointer;
  font-weight: 700;
}

.vitals-panel {
  margin-top: 12px;
  box-shadow: none;
}

.sample-count {
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.72rem;
  text-align: end;
}

.sample-count strong {
  color: var(--text);
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
}

.vital-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  padding: 15px;
}

.vital-card > div {
  display: flex;
  min-height: 28px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
}

.vital-card abbr {
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.74rem;
  font-weight: 800;
  text-decoration: none;
}

.vital-rating {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.2;
}

.vital-card.good .vital-rating {
  border-color: color-mix(in srgb, var(--green) 45%, var(--border));
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--green);
}

.vital-card.needs-improvement .vital-rating {
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
  background: var(--warning-bg);
  color: var(--warning);
}

.vital-card.poor .vital-rating {
  border-color: color-mix(in srgb, var(--red) 45%, var(--border));
  background: var(--red-soft);
  color: var(--red);
}

.vital-card > strong {
  display: block;
  margin-top: 13px;
  font-family: var(--font-data);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  letter-spacing: -0.05em;
  line-height: 1;
}

.vital-card > small {
  display: block;
  min-height: 34px;
  margin-top: 9px;
  color: var(--text-muted);
  font-size: 0.66rem;
  line-height: 1.45;
}

.compact-empty {
  min-height: 110px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

th,
td {
  border-block-end: 1px solid var(--border);
  padding: 10px 14px;
  text-align: start;
}

th {
  background: var(--surface-muted);
  color: var(--text);
}

td:not(:first-child) {
  font-family: var(--font-data);
}

tbody tr:last-child td {
  border-block-end: 0;
}

.dashboard-section {
  scroll-margin-block-start: 24px;
  margin-top: 70px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 14px;
}

.funnel-panel {
  display: grid;
  grid-template-columns: minmax(190px, 0.32fr) minmax(0, 1fr);
  gap: 28px;
  margin-bottom: 14px;
  box-shadow: none;
}

.funnel-summary h3 {
  max-width: 14ch;
  margin: 0;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  letter-spacing: -0.035em;
  line-height: 1.25;
}

.funnel-rates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 24px;
}

.funnel-rates > span {
  border-block-start: 2px solid var(--red);
  padding-top: 8px;
}

.funnel-rates small,
.funnel-rates strong {
  display: block;
}

.funnel-rates small {
  min-height: 38px;
  color: var(--text-muted);
  font-size: 0.63rem;
  line-height: 1.4;
}

.funnel-rates strong {
  margin-top: 4px;
  font-family: var(--font-data);
  font-size: 1.35rem;
}

.funnel-list {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.funnel-list li {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 190px;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--bg);
  padding: 14px;
}

.funnel-list li::after {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: -11px;
  z-index: 2;
  width: 14px;
  border-block-start: 1px solid var(--red);
  content: '';
}

.funnel-list li:last-child::after {
  display: none;
}

.funnel-index {
  color: var(--red);
  font-family: var(--font-data);
  font-size: 0.64rem;
  font-weight: 800;
}

.funnel-list li > strong {
  min-height: 46px;
  margin-top: 11px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.funnel-list li > b {
  margin-top: auto;
  font-family: var(--font-data);
  font-size: 1.45rem;
}

.funnel-list progress {
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border: 0;
  border-radius: 99px;
  margin-top: 10px;
  background: var(--surface-muted);
  color: var(--red);
  accent-color: var(--red);
  appearance: none;
}

.funnel-list progress::-webkit-progress-bar {
  background: var(--surface-muted);
}

.funnel-list progress::-webkit-progress-value {
  background: var(--red);
}

.funnel-list progress::-moz-progress-bar {
  background: var(--red);
}

.funnel-list li > small {
  display: block;
  min-height: 32px;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 0.59rem;
  line-height: 1.35;
}

.panel-total {
  color: var(--red);
  font-family: var(--font-data);
  font-size: 1.5rem;
}

.ranking-list {
  display: grid;
  gap: 15px;
  margin: 0;
  padding: 0;
  counter-reset: ranking;
  list-style: none;
}

.ranking-list li {
  display: grid;
  min-width: 0;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  counter-increment: ranking;
}

.ranking-list li::before {
  color: var(--text-muted);
  content: counter(ranking, decimal-leading-zero);
  font-family: var(--font-data);
  font-size: 0.68rem;
}

.ranking-label {
  min-width: 0;
}

.ranking-label span {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-label progress {
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  margin-top: 7px;
  background: var(--surface-muted);
  color: var(--red);
  appearance: none;
}

.ranking-label progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-muted);
}

.ranking-label progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--red);
}

.ranking-label progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--red);
}

.ranking-value {
  min-width: 44px;
  color: var(--text-muted);
  font-family: var(--font-data);
  font-size: 0.75rem;
  text-align: end;
}

.ranking-list.compact {
  gap: 12px;
}

.empty-state {
  display: grid;
  min-height: 180px;
  margin: 0;
  place-items: center;
  color: var(--text-muted);
  text-align: center;
}

.audience-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.mini-panel {
  border-radius: var(--radius);
  box-shadow: none;
}

.mini-panel .panel-title {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-block-end: 1px solid var(--border);
}

.dashboard-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-block-start: 1px solid var(--border);
  margin-top: 70px;
  padding-top: 20px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.dashboard-footer span:first-child {
  color: var(--text);
  font-weight: 850;
}

.skeleton-text {
  position: relative;
  color: transparent !important;
}

.skeleton-text::before {
  position: absolute;
  inset: 0;
  width: 70%;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--surface-muted),
    var(--border),
    var(--surface-muted)
  );
  background-size: 200% 100%;
  content: '';
  animation: shimmer 1.2s ease-in-out infinite;
}

.primary-kpi .skeleton-text::before {
  background: linear-gradient(90deg, #222226, #3a3a40, #222226);
  background-size: 200% 100%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.language-switch {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 11px 6px 13px;
  cursor: pointer;
  text-align: start;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    translate 180ms ease;
}

.language-switch:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.language-switch:active {
  translate: 0 1px;
}

.language-switch > svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
}

.language-switch .switch-arrow {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

[dir='rtl'] .language-switch .switch-arrow {
  rotate: 180deg;
}

.language-switch span,
.language-switch small,
.language-switch strong {
  display: block;
}

.language-switch small {
  color: var(--text-muted);
  font-size: 0.62rem;
  line-height: 1.1;
}

.language-switch strong {
  min-width: 52px;
  margin-top: 2px;
  font-size: 0.76rem;
  line-height: 1.1;
}

.numeric,
.kpi-card strong,
.kpi-card small,
.vital-card strong,
.panel-total,
.ranking-list strong,
.funnel-list b,
.funnel-rates strong,
td:not(:first-child),
.sample-count,
.range-control button,
.section-index,
.panel-number {
  direction: ltr;
  font-variant-numeric: tabular-nums;
  unicode-bidi: isolate;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.back-button:hover {
  color: var(--red);
}

.back-button svg {
  width: 18px;
  height: 18px;
}

[dir='rtl'] .back-button svg {
  rotate: 180deg;
}

.mfa-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 18px 0;
}

.mfa-methods button {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 750;
}

.mfa-methods button:hover,
.mfa-methods button.active {
  border-color: var(--text);
  background: var(--surface-strong);
  color: var(--text-on-dark);
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.secondary-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 750;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    color 180ms ease;
}

.secondary-button:hover {
  border-color: var(--text);
  background: var(--surface-muted);
}

.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.compact-button {
  width: 100%;
  min-height: 44px;
  margin-bottom: 14px;
}

.fit-button {
  width: auto;
  min-width: 190px;
  gap: 24px;
}

.security-main {
  max-width: 1420px;
}

.security-header {
  margin-bottom: 42px;
}

.status-banner {
  position: sticky;
  z-index: 40;
  inset-block-start: 12px;
  border: 1px solid color-mix(in srgb, var(--green) 50%, var(--border));
  border-radius: 14px;
  margin-bottom: 22px;
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--text);
  padding: 13px 16px;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.status-banner.error {
  border-color: color-mix(in srgb, var(--red) 55%, var(--border));
  background: var(--red-soft);
  color: var(--red);
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(230px, 0.34fr) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
  padding: clamp(24px, 4vw, 44px);
}

.settings-intro {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.settings-intro h3,
.security-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.settings-intro p,
.security-card > p {
  margin: 9px 0 0;
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.75;
}

.settings-icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--red-soft);
  color: var(--red);
}

.settings-icon svg {
  width: 23px;
  height: 23px;
}

.settings-form {
  min-width: 0;
}

.settings-form .field + .field {
  margin-top: 0;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.form-row.three-columns {
  grid-template-columns: minmax(0, 1.4fr) minmax(120px, 0.5fr) minmax(0, 1fr);
}

.field select {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  padding: 12px 15px;
}

.settings-form > .primary-button,
.button-row {
  margin-top: 24px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

.security-card {
  display: flex;
  min-height: 285px;
  flex-direction: column;
  box-shadow: none;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

.security-card > .secondary-button {
  width: 100%;
  margin-top: auto;
}

.status-chip,
.security-score {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 800;
}

.status-chip.enabled {
  border-color: color-mix(in srgb, var(--green) 40%, var(--border));
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  color: var(--green);
}

.danger-button {
  border-color: color-mix(in srgb, var(--red) 45%, var(--border)) !important;
  color: var(--red) !important;
}

.danger-button:hover {
  background: var(--red-soft) !important;
}

.smtp-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.smtp-note svg {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  color: var(--red);
}

.smtp-note p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.8;
}

.secure-dialog {
  width: min(92vw, 560px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  padding: clamp(22px, 4vw, 34px);
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.3);
}

.secure-dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(8px);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  line-height: 1.25;
}

.dialog-heading p {
  margin: 7px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.65;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.qr-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 20px;
  background: var(--bg);
  padding: 14px;
}

.qr-layout img {
  width: 190px;
  height: 190px;
  border-radius: 10px;
  background: #fff;
}

.secret-code {
  display: block;
  overflow-wrap: anywhere;
  color: var(--red);
  font-family: var(--font-data);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.8;
}

.recovery-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recovery-list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 9px 11px;
  text-align: center;
}

.recovery-list code {
  font-family: var(--font-data);
  font-size: 0.82rem;
  font-weight: 800;
}

@media (max-width: 1280px) {
  .security-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recovery-card {
    grid-column: 1 / -1;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .audience-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vitals-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .funnel-panel {
    grid-template-columns: 1fr;
  }

  .funnel-summary {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 0.65fr);
    align-items: end;
    gap: 20px;
  }

  .funnel-summary .eyebrow {
    grid-column: 1 / -1;
  }

  .funnel-rates {
    margin-top: 0;
  }
}

@media (max-width: 1024px) {
  .login-shell {
    grid-template-columns: 1fr minmax(340px, 0.85fr);
  }

  .login-story,
  .login-panel {
    padding: 40px;
  }

  .privacy-list {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .privacy-list li + li {
    border-inline-start: 0;
  }

  .dashboard-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: 50;
    inset-block-start: 0;
    display: grid;
    width: 100%;
    height: auto;
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 10px 16px;
  }

  .sidebar-brand {
    border: 0;
    padding: 0;
  }

  .sidebar-brand img {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .sidebar-brand span,
  .sidebar-foot {
    display: none;
  }

  .sidebar-nav {
    display: flex;
    min-width: 0;
    justify-content: flex-end;
    gap: 4px;
    margin: 0;
  }

  .nav-item {
    min-height: 44px;
    gap: 7px;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .dashboard-main {
    padding-top: 28px;
  }

  .settings-panel {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 760px) {
  .login-toolbar {
    position: absolute;
    inset-block-start: 16px;
    inset-inline-end: 16px;
  }

  .login-shell {
    display: block;
  }

  .login-story {
    min-height: auto;
    border-inline-end: 0;
    padding: 22px 20px 34px;
  }

  .story-brand {
    padding-inline-end: 190px;
  }

  .story-brand img {
    width: 50px;
    height: 50px;
    border-radius: 15px;
  }

  .story-copy {
    padding: 70px 0 32px;
  }

  .story-copy h1 {
    max-width: 13ch;
    font-size: clamp(2.45rem, 13vw, 4rem);
  }

  .privacy-list {
    display: none;
  }

  .login-panel {
    min-height: auto;
    border-radius: 28px 28px 0 0;
    padding: 50px 20px 34px;
  }

  .panel-number {
    inset-block-start: 18px;
    inset-inline-start: 20px;
  }

  .dashboard-header {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 38px;
  }

  .dashboard-header h1 {
    font-size: 2.3rem;
  }

  .header-actions {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
  }

  .header-actions .icon-button:last-child {
    margin-inline-start: auto;
  }

  .section-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .range-control {
    width: 100%;
  }

  .range-control button {
    min-width: 0;
    flex: 1;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-card {
    min-height: 148px;
    padding: 16px;
  }

  .kpi-card strong {
    font-size: 1.65rem;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-legend {
    justify-content: flex-start;
  }

  .split-grid,
  .audience-grid {
    grid-template-columns: 1fr;
  }

  .vitals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .funnel-summary {
    display: block;
  }

  .funnel-rates {
    margin-top: 20px;
  }

  .funnel-list {
    grid-template-columns: 1fr;
  }

  .funnel-list li {
    display: grid;
    min-height: 0;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 10px;
  }

  .funnel-list li::after {
    inset-block-start: auto;
    inset-block-end: -10px;
    inset-inline-end: 50%;
    width: 0;
    height: 10px;
    border-block-start: 0;
    border-inline-start: 1px solid var(--red);
  }

  .funnel-list li > strong,
  .funnel-list li > b {
    min-height: 0;
    margin: 0;
  }

  .funnel-list progress,
  .funnel-list li > small {
    grid-column: 2 / -1;
    margin-top: 0;
  }

  .funnel-list li > small {
    min-height: 0;
  }

  .dashboard-section {
    margin-top: 54px;
  }

  .security-card-grid,
  .form-row,
  .form-row.three-columns {
    grid-template-columns: 1fr;
  }

  .recovery-card {
    grid-column: auto;
  }

  .security-card {
    min-height: 245px;
  }

  .settings-panel {
    padding: 20px;
  }

  .qr-layout {
    grid-template-columns: 1fr;
  }

  .qr-layout img {
    width: min(100%, 230px);
    height: auto;
    margin-inline: auto;
  }
}

@media (max-width: 520px) {
  .sidebar {
    grid-template-columns: 42px minmax(0, 1fr);
    padding-inline: 10px;
  }

  .sidebar-nav {
    justify-content: stretch;
  }

  .nav-item {
    min-width: 44px;
    flex: 1;
    justify-content: center;
  }

  .nav-item span {
    display: none;
  }

  .dashboard-main {
    padding-inline: 14px;
  }

  .header-subtitle {
    max-width: 20ch;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .language-switch {
    flex: 1;
  }

  .header-actions .icon-button {
    min-width: 44px;
    min-height: 44px;
  }

  .kpi-grid {
    gap: 8px;
  }

  .kpi-label {
    min-height: 38px;
  }

  .panel {
    border-radius: 20px;
    padding: 17px;
  }

  .vitals-grid {
    gap: 7px;
  }

  .vital-card {
    padding: 12px;
  }

  .vital-card > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .vital-card > strong {
    font-size: 1.35rem;
  }

  .trend-svg {
    height: 220px;
  }

  .dashboard-footer {
    flex-direction: column;
  }

  .login-toolbar {
    inset-inline: 12px;
    justify-content: flex-end;
  }

  .login-toolbar .language-switch small {
    display: none;
  }

  .login-toolbar .language-switch strong {
    min-width: 42px;
  }

  .story-brand {
    padding-inline-end: 152px;
  }

  .story-brand span {
    display: none;
  }

  .mfa-methods,
  .recovery-list {
    grid-template-columns: 1fr;
  }

  .dialog-actions,
  .button-row {
    flex-direction: column-reverse;
  }

  .dialog-actions .primary-button,
  .dialog-actions .secondary-button,
  .button-row .primary-button,
  .button-row .secondary-button,
  .settings-form > .primary-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
