
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:        #3a45ff;
  --blue-dark:   #2830cc;
  --green:       #18c96a;
  --orange:      #ff9f1c;
  --violet:      #8b5cf6;
  --red:         #ff3b3b;
  --grey-bg:     #f3f6fb;
  --grey-border: #e2e2e8;
  --grey-text:   #8e8e9a;
  --text:        #1a1a2e;
  --white:       #ffffff;
  --radius:      14px;
  --radius-sm:   8px;
  --header-h:    58px;
}

html, body {
  height: 100%;
  background: var(--grey-bg);
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}


.m-login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grey-bg);
}

.m-login__card {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  padding: 40px 32px 32px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}

.m-login__logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.m-login__title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.m-login__sub {
  font-size: 13px;
  color: var(--grey-text);
  text-align: center;
  margin-top: -4px;
}

.m-login__error {
  font-size: 13px;
  color: var(--red);
  text-align: center;
}


.m-app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}


.m-header {
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
  display: flex !important;
  align-items: center;
  flex-wrap: nowrap;
  padding: 0 20px;
  height: var(--header-h);
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.m-header__logo { display: block; flex-shrink: 0; }


.m-header__spacer { flex: 1 1 0; min-width: 0; max-width: 100%; }


.m-header__divider {
  width: 1px;
  height: 22px;
  background: var(--grey-border);
  flex-shrink: 0;
  margin: 0 2px;
}

.m-header__sep {
  color: var(--grey-text);
  font-size: 13px;
  flex-shrink: 0;
  user-select: none;
}


.m-btn--icon {
  height: 32px;
  width: 32px;
  padding: 0;
  background: transparent;
  border: 1.5px solid var(--grey-border);
  color: var(--grey-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.m-btn--icon:hover { background: var(--grey-bg); color: var(--text); border-color: #ccc; }


.m-btn--icon .m-icon-svg {
  display: block;
  opacity: 0.55;
  transition: opacity .15s;
}
.m-btn--icon:hover .m-icon-svg { opacity: 0.85; }


.m-header__left { display: flex; align-items: center; flex-shrink: 0; }
.m-header__controls { display: flex; align-items: center; gap: 8px; }
.m-header__title { font-size: 17px; font-weight: 700; color: var(--text); }




.m-input {
  height: 36px;
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.m-input:focus { border-color: var(--blue); }
.m-input--date { width: 136px; }

.m-select {
  height: 36px;
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  color: var(--text);
  background: var(--white);
  outline: none;
  cursor: pointer;
  max-width: 160px;
}


.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
  user-select: none;
}
.m-btn:disabled { opacity: .5; pointer-events: none; }
.m-btn--primary   { background: var(--blue);        color: #fff; }
.m-btn--primary:hover   { background: var(--blue-dark); }
.m-btn--secondary { background: var(--grey-border); color: var(--text); }
.m-btn--secondary:hover { background: #d6d6e0; }
.m-btn--ghost     { background: transparent;        color: var(--grey-text); }
.m-btn--ghost:hover     { background: var(--grey-bg); }
.m-btn--sm   { height: 32px; padding: 0 12px; font-size: 13px; }
.m-btn--full { width: 100%; height: 42px; font-size: 15px; }


.m-main {
  flex: 1;
  padding: 22px 20px 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}


.m-loading, .m-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 320px;
  color: var(--grey-text);
  font-size: 15px;
}

.m-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--grey-border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


.m-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.m-card {
  background: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.m-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.m-card__icon--blue   { background: rgba(58,69,255,.1);  color: var(--blue); }
.m-card__icon--green  { background: rgba(24,201,106,.1); color: var(--green); }
.m-card__icon--violet { background: rgba(139,92,246,.1); color: var(--violet); }
.m-card__icon--orange { background: rgba(255,159,28,.1); color: var(--orange); }

.m-card__val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.m-card__lbl {
  font-size: 12px;
  color: var(--grey-text);
  margin-top: 2px;
}


.m-section {
  background: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
}

.m-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.m-section__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
}
.m-section__hint {
  font-size: 12px;
  color: var(--grey-text);
  margin-top: -10px;
  margin-bottom: 12px;
}
.m-section__head .m-section__title { margin-bottom: 0; }


.m-chart-wrap {
  height: 240px;
  position: relative;
}

.m-legend {
  display: flex;
  align-items: center;
  gap: 12px;
}

.m-legend__dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.m-legend__dot--blue  { background: var(--blue); }
.m-legend__dot--green { background: var(--green); }
.m-legend__lbl { font-size: 12px; color: var(--grey-text); }


.m-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}
.m-grid--2 { grid-template-columns: 1fr 1fr; }
.m-grid--3 { grid-template-columns: repeat(3, 1fr); }
.m-grid > .m-section { margin-bottom: 0; }
.m-section { margin-bottom: 16px; }
.m-section:last-child { margin-bottom: 0; }


.m-table-wrap { overflow-x: auto; }

.m-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.m-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--grey-text);
  border-bottom: 1px solid var(--grey-border);
}

.m-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--grey-border);
  color: var(--text);
}

.m-table tr:last-child td { border-bottom: none; }
.m-table tbody tr:hover td { background: var(--grey-bg); }

.m-table__url {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.m-table__empty {
  color: var(--grey-text);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}


.m-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}

.m-bar-row:last-child { margin-bottom: 0; }

.m-bar-row__label {
  width: 80px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.m-bar-row__track {
  flex: 1;
  height: 8px;
  background: var(--grey-bg);
  border-radius: 4px;
  overflow: hidden;
}

.m-bar-row__fill {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  transition: width .5s ease;
  min-width: 2px;
}

.m-bar-row__val {
  width: 36px;
  text-align: right;
  color: var(--grey-text);
  flex-shrink: 0;
  font-size: 12px;
}

.m-empty {
  color: var(--grey-text);
  font-size: 13px;
  padding: 14px 0;
  text-align: center;
}

.m-empty-row {
  color: var(--grey-text);
  font-size: 13px;
  text-align: center;
  padding: 14px !important;
}


.m-section--inline { padding: 14px 18px; }

.m-nv {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
}

.m-nv__block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.m-nv__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.m-nv__icon--blue  { background: rgba(58,69,255,.1);  color: var(--blue); }
.m-nv__icon--green { background: rgba(24,201,106,.1); color: var(--green); }

.m-nv__val { font-size: 22px; font-weight: 700; line-height: 1.1; }
.m-nv__lbl { font-size: 12px; color: var(--grey-text); margin-top: 2px; }

.m-nv__sep {
  width: 1px;
  height: 40px;
  background: var(--grey-border);
  flex-shrink: 0;
}

.m-nv__bar-wrap {
  flex: 1;
  min-width: 180px;
}

.m-nv__bar-track {
  height: 10px;
  background: rgba(24,201,106,.2);
  border-radius: 5px;
  overflow: hidden;
}

.m-nv__bar-new {
  height: 100%;
  background: var(--blue);
  border-radius: 5px;
  transition: width .6s ease;
}

.m-nv__bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--grey-text);
  margin-top: 4px;
}


.m-funnel-builder {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.m-funnel-step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m-funnel-step__num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.m-funnel-step__input {
  flex: 1;
  max-width: 360px;
}

.m-funnel-result {
  margin-top: 20px;
}

.m-funnel-empty {
  color: var(--grey-text);
  font-size: 13px;
  padding: 16px 0 4px;
}

.m-funnel-bar {
  margin-bottom: 16px;
}

.m-funnel-bar__drop {
  display: block;
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}


.m-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.m-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.m-modal__content {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}

.m-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--grey-border);
  position: sticky;
  top: 0;
  background: var(--white);
}

.m-modal__header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.m-modal__close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--grey-text);
  transition: color 0.2s;
}

.m-modal__close:hover {
  color: var(--text);
}

.m-modal__body {
  padding: 24px;
}


.m-integration__section {
  margin-bottom: 20px;
}

.m-integration__section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.m-integration__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-integration__code-block {
  background: #f5f5f5;
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  overflow-x: auto;
}

.m-integration__code-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #333;
  line-height: 1.5;
}

.m-integration__code-block code {
  background: none;
  padding: 0;
}


.m-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--grey-border);
}

.m-tab {
  background: none;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--grey-text);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-weight: 500;
}

.m-tab:hover {
  color: var(--text);
}

.m-tab--active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.m-tab-content {
  display: none;
  animation: fadeIn 0.2s;
}

.m-tab-content p {
  margin-bottom: 12px;
  color: #666;
}

.m-tab-content ol {
  padding-left: 20px;
}

.m-tab-content li {
  margin-bottom: 8px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.m-funnel-bar__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.m-funnel-bar__step {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.m-funnel-bar__pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
}

.m-funnel-bar__track {
  height: 32px;
  background: var(--grey-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.m-funnel-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, #6b75ff 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 10px;
  transition: width .7s ease;
  min-width: 36px;
}

.m-funnel-bar__count {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}


.m-period-picker {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
  background: var(--grey-bg);
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.m-period-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--grey-text);
  transition: all 0.15s;
  white-space: nowrap;
  display: none;
  height: 26px;
  line-height: 1;
}

.m-period-btn:hover {
  background: var(--white);
  color: var(--text);
}

.m-period-btn.m-period-btn--active {
  background: var(--white);
  color: var(--blue);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}


.m-period-picker--visible .m-period-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


@media (max-width: 1100px) {
  .m-grid--3 { grid-template-columns: 1fr 1fr; }
}


@media (max-width: 1024px) {
  .m-input--date { width: 108px; font-size: 13px; }
  .m-select { max-width: 130px; font-size: 13px; }
  .m-header { gap: 6px; padding: 0 14px; }
}


@media (max-width: 860px) {
  .m-cards { grid-template-columns: repeat(2, 1fr); }
  .m-grid--2, .m-grid--3 { grid-template-columns: 1fr; }
  .m-nv { gap: 14px; }
  .m-nv__sep { display: none; }

  .m-header {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }

  
  .m-header__logo { order: 0; }
  .m-header__spacer { order: 1; flex: 1; }
  #logout-btn { order: 2; }

  
  .m-select,
  .m-period-picker,
  #date-from,
  .m-header__sep,
  #date-to,
  #refresh-btn,
  .m-header__divider,
  #integration-btn {
    order: 10;
  }

  
  .m-period-picker { width: 100%; order: 11; }
  .m-period-picker .m-period-btn { flex: 1; }

  .m-input--date { width: auto; flex: 1; min-width: 80px; }
  .m-select { min-width: 110px; max-width: none; flex: 1; }
  .m-header__divider { display: none; }
}


@media (max-width: 600px) {
  .m-cards { grid-template-columns: repeat(2, 1fr); }
  .m-card { padding: 12px; }
  .m-card__val { font-size: 18px; }

  .m-header { padding: 8px 10px; }
  .m-input--date { width: auto; min-width: 72px; font-size: 12px; }
  .m-btn--sm { font-size: 12px; padding: 0 10px; }
  .m-header__logo { height: 28px; }

  .m-period-picker .m-period-btn { font-size: 11px; padding: 3px 6px; }
}


@media (max-width: 420px) {
  .m-cards { grid-template-columns: 1fr; }
  .m-main  { padding: 10px 8px 20px; }
}

