/* Mini App traffic-link controls and mobile typography stabilization. */

html,
body,
button,
input,
textarea,
select {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

button,
input,
textarea,
select {
  letter-spacing: inherit;
}

input,
textarea,
select {
  font-size: 16px;
  line-height: 1.35;
}

button {
  line-height: 1.2;
}

.traffic-links-section {
  min-width: 0;
}

.traffic-links-heading {
  align-items: center;
}

.traffic-links-heading > div:first-child {
  min-width: 0;
}

.traffic-links-heading p {
  max-width: 620px;
}

.traffic-heading-actions,
.traffic-link-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.traffic-refresh-btn,
.traffic-icon-btn {
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
}

.traffic-delete-btn {
  color: var(--danger);
}

.traffic-create-btn {
  min-height: 42px;
  white-space: nowrap;
}

.traffic-links-list {
  display: grid;
  gap: 10px;
}

.traffic-link-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
}

.traffic-link-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.traffic-link-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.traffic-link-title > div {
  min-width: 0;
}

.traffic-link-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--cyan);
  background: var(--cyan-soft);
}

.traffic-link-icon svg {
  width: 17px;
  height: 17px;
}

.traffic-link-title h3 {
  overflow: hidden;
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.traffic-link-title code {
  overflow: hidden;
  display: block;
  max-width: min(62vw, 620px);
  margin-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.traffic-link-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.traffic-link-stats > div {
  min-width: 0;
  padding: 10px 11px;
  border-right: 1px solid var(--line);
}

.traffic-link-stats > div:last-child {
  border-right: 0;
}

.traffic-link-stats span,
.traffic-link-stats strong {
  overflow: hidden;
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.traffic-link-stats span {
  color: var(--faint);
  font-size: 9px;
  line-height: 1.25;
}

.traffic-link-stats strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  line-height: 1.25;
}

.traffic-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  color: var(--muted);
}

.traffic-empty > span {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--cyan);
  background: var(--cyan-soft);
}

.traffic-empty b {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.traffic-empty p {
  margin: 3px 0 0;
  font-size: 11px;
  line-height: 1.45;
}

.traffic-form {
  display: grid;
  gap: 16px;
}

.traffic-field {
  display: grid;
  gap: 7px;
}

.traffic-field > span {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.traffic-field > small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.traffic-field input {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: var(--surface-2);
}

.traffic-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.traffic-submit {
  min-height: 50px;
}

.traffic-delete-copy {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.traffic-delete-copy b {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.traffic-delete-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .traffic-links-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .traffic-heading-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .traffic-create-btn {
    width: 100%;
    padding-inline: 12px;
  }

  .traffic-link-head {
    align-items: flex-start;
  }

  .traffic-link-title {
    align-items: flex-start;
  }

  .traffic-link-title code {
    max-width: calc(100vw - 190px);
  }

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

  .traffic-link-stats > div {
    min-height: 54px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .traffic-link-stats > div:nth-child(2n) {
    border-right: 0;
  }

  .traffic-link-stats > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .traffic-link-stats span {
    font-size: 10px;
  }

  .traffic-link-stats strong {
    font-size: 13px;
  }

  .traffic-form,
  .traffic-delete-copy,
  .traffic-field,
  .traffic-field input,
  .traffic-submit {
    min-width: 0;
    max-width: 100%;
  }

  .traffic-field input {
    font-size: 16px !important;
  }

  .sheet-body {
    min-width: 0;
  }
}

@media (max-width: 390px) {
  .traffic-link-card {
    padding: 13px;
  }

  .traffic-link-icon {
    display: none;
  }

  .traffic-link-title code {
    max-width: calc(100vw - 150px);
  }

  .traffic-link-actions {
    gap: 5px;
  }

  .traffic-refresh-btn,
  .traffic-icon-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
}


.traffic-users-list {
  display: grid;
  gap: 9px;
}

.traffic-user-row {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

.traffic-user-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.traffic-user-main b,
.traffic-user-main span,
.traffic-user-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.traffic-user-main b {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.traffic-user-main span {
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  text-align: right;
}

.traffic-user-row small,
.traffic-users-loading,
.traffic-users-error {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.traffic-users-loading,
.traffic-users-error {
  margin-top: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}

@media (max-width: 700px) {
  .traffic-user-main {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .traffic-user-main span {
    text-align: left;
  }
}
