:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #697386;
  --line: #e7ebf2;
  --primary: #111827;
  --primary2: #263248;
  --soft: #f1f4f8;
  --success: #16845b;
  --danger: #d63c4a;
  --warning: #b7791f;
  --radius: 20px;
  --shadow: 0 14px 40px rgba(20, 31, 50, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Arial, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  padding: 22px 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 25px rgba(17, 24, 39, 0.15);
}

.brand h1 {
  font-size: 20px;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.5px;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.ad-slot {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 16px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 14px;
}

.ad-placeholder {
  width: 100%;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a1a8b5;
  font-size: 11px;
  border: 1px dashed #dce1e9;
  border-radius: 14px;
  background: #fafbfc;
}

.main {
  padding: 8px 0 45px;
}

.hero {
  text-align: center;
  padding: 30px 0 20px;
}

.hero h2 {
  margin: 0;
  font-size: clamp(28px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: -1.8px;
}

.hero p {
  max-width: 620px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 15px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-card {
  width: 100%;
  padding: 22px;
  margin-left: auto;
  margin-right: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-title h3 {
  margin: 0;
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.field {
  margin-bottom: 15px;
}

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

.input-wrap {
  position: relative;
}

.input-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa3b2;
  pointer-events: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--text);
  border-radius: 13px;
  outline: none;
  transition: 0.18s ease;
}

input,
select {
  height: 48px;
  padding: 0 14px;
}

.input-wrap input {
  padding-left: 42px;
}

textarea {
  min-height: 100px;
  resize: vertical;
  padding: 13px 14px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #aeb8c8;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.045);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.btn {
  border: 0;
  border-radius: 12px;
  min-height: 45px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
  transition: 0.18s ease;
}

#saveBtn {
  width: 100%;
  min-height: 54px;
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 20px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
}

#saveBtn:disabled {
  width: 100%;
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: var(--soft);
  color: var(--text);
}

.btn-danger {
  background: #fff0f1;
  color: var(--danger);
}

.btn-success {
  background: #eaf8f2;
  color: var(--success);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.manager-card {
  width: 100%;
  margin: 18px auto 0;
  overflow: hidden;
}

.manager-head {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.manager-head h3 {
  margin: 0;
  font-size: 17px;
}

.link-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.link-toolbar .search {
  max-width: 300px;
  flex: 1 1 240px;
}

.link-toolbar select {
  min-width: 140px;
}

.links {
  padding: 8px;
}

.link-item {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.link-item:last-child {
  border-bottom: 0;
}

.link-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.link-title {
  font-weight: 800;
  word-break: break-all;
}

.link-destination {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  word-break: break-all;
  max-width: 700px;
}

.link-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: #596274;
  font-size: 11px;
  font-weight: 700;
}

.badge.success {
  color: var(--success);
  background: #eaf8f2;
}

.badge.danger {
  color: var(--danger);
  background: #fff0f1;
}

.link-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.mini-btn {
  border: 0;
  background: var(--soft);
  color: var(--text);
  min-height: 35px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}

.mini-btn.danger {
  background: #fff0f1;
  color: var(--danger);
}

.link-actions .mini-btn {
  cursor: pointer;
}

.link-actions .mini-btn.danger:hover {
  background: #ffe0e3;
}

@media (max-width: 700px) {
  .link-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .link-actions .mini-btn {
    width: 100%;
    justify-content: center;
  }
}

.empty {
  text-align: center;
  padding: 45px 20px;
  color: var(--muted);
}

.empty i {
  font-size: 28px;
  margin-bottom: 10px;
  color: #b5bdca;
}

.footer {
  text-align: center;
  color: #929baa;
  font-size: 11px;
  padding: 0 0 30px;
}

html.redirect-route .manager-view,
html.redirect-route .manager-ad,
html.redirect-route .manager-footer,
body.redirect-mode .manager-view,
body.redirect-mode .manager-ad,
body.redirect-mode .manager-footer {
  display: none !important;
}

html.redirect-route .redirect-view,
body.redirect-mode .redirect-view {
  display: flex !important;
}

html.manager-route .redirect-view,
body.manager-mode .redirect-view {
  display: none !important;
}

.redirect-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.redirect-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0 30px;
}

.redirect-center > .container {
  display: flex;
  justify-content: center;
  width: min(1180px, calc(100% - 32px));
}

.redirect-card {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 30px;
  text-align: center;
}

.redirect-icon {
  width: 62px;
  height: 62px;
  border-radius: 19px;
  margin: 0 auto 17px;
  display: grid;
  place-items: center;
  background: #111827;
  color: #fff;
  font-size: 23px;
}

.redirect-card h2 {
  margin: 0;
  font-size: 24px;
}

.redirect-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 9px auto 20px;
}

.countdown {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  margin: 18px 0;
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  min-height: 65px;
  margin: 18px 0;
}

.redirect-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  text-align: left;
}

.redirect-brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(17, 24, 39, 0.12);
}

.redirect-brand strong,
.redirect-brand span {
  display: block;
}

.redirect-brand strong {
  font-size: 14px;
  letter-spacing: -0.2px;
}

.redirect-brand span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 2px;
}

.countdown-label {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.countdown-label strong {
  color: var(--text);
}

.countdown {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: -2px;
  margin: 4px 0 18px;
}

.password-panel {
  margin: 15px 0;
  text-align: left;
}

.status {
  min-height: 22px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

.redirect-home-btn {
  width: 100%;
  margin-top: 10px;
  text-decoration: none;
}

.redirect-home-btn:hover {
  text-decoration: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 26, 0.52);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(460px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.close {
  border: 0;
  background: var(--soft);
  width: 35px;
  height: 35px;
  border-radius: 10px;
}

.result-url {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.result-url input {
  flex: 1;
}

.qr-box {
  min-height: 220px;
  display: grid;
  place-items: center;
  margin: 10px 0;
}

#qrCanvas {
  width: 100%;
  min-height: 240px;
  display: grid;
  place-items: center;
  align-content: center;
  justify-items: center;
  overflow: hidden;
  box-sizing: border-box;
}

#qrCanvas .qr-render {
  display: block;
  width: min(240px, 72vw) !important;
  height: min(240px, 72vw) !important;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto !important;
  background: #fff;
  image-rendering: auto;
}

#qrCanvas .hint {
  text-align: center;
}


.share-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 15px;
}

.share-btn {
  border: 0;
  background: var(--soft);
  min-height: 42px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #111827;
  color: #fff;
  padding: 11px 15px;
  border-radius: 11px;
  font-size: 12px;
  z-index: 2000;
  transition: 0.2s ease;
  max-width: calc(100% - 30px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

@media (min-width: 1200px) {
  .form-card {
    padding: 28px 30px;
  }

  .redirect-card {
    max-width: 820px;
    padding: 34px;
  }

  #saveBtn {
    min-height: 56px;
    font-size: 16px;
    border-radius: 14px;
  }
}

@media (max-width: 900px) {
  #saveBtn {
    width: 100%;
    min-height: 54px;
  }
}

@media (max-width: 700px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .manager-head {
    align-items: stretch;
    flex-direction: column;
  }

  .link-toolbar {
    width: 100%;
    justify-content: stretch;
  }

  .link-toolbar .search {
    max-width: none;
    flex-basis: 100%;
  }

  .link-toolbar select {
    flex: 1 1 0;
    min-width: 0;
  }

  .link-main {
    flex-direction: column;
  }

  .redirect-card {
    padding: 21px;
  }

  #saveBtn {
    width: 100%;
    min-height: 54px;
    padding: 0 18px;
    font-size: 15px;
    border-radius: 14px;
  }
}

@media (max-width: 480px) {
  #resultModal {
    padding: 10px;
  }

  #resultModal .modal-card {
    width: 100%;
    max-height: 94vh;
    padding: 17px;
    border-radius: 18px;
  }

  #resultModal .actions {
    grid-template-columns: 1fr;
  }

  #resultModal .actions > #generateQr {
    grid-column: auto;
  }

  .container,
  .redirect-center > .container {
    width: calc(100% - 20px);
  }

  .form-card {
    padding: 17px;
  }

  .hero {
    padding-top: 22px;
  }

  .hero h2 {
    font-size: 31px;
  }

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

  .ad-placeholder,
  .ad-slot {
    min-height: 70px;
  }

  #saveBtn {
    width: 100%;
    min-height: 52px;
    padding: 0 15px;
    font-size: 15px;
    border-radius: 13px;
  }
}

#resultModal #generateQr {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-height: 56px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
}

#resultModal .actions {
  display: flex;
  width: 100%;
  flex-direction: column;
  box-sizing: border-box;
}

#resultModal .actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#resultModal .actions > #generateQr {
  grid-column: 1 / -1;
  width: 100%;
}

.result-analysis {
  margin: 12px 0 4px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}
.qr-overlay {
  position: relative !important;
  display: inline-grid !important;
  place-items: center;
}
.qr-overlay .qr-logo {
  position: absolute;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  padding: 4px;
  background: #fff;
  box-sizing: border-box;
}

.analytics-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 55vh;
  overflow: auto;
}
.analytics-item {
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.analytics-item strong {
  color: var(--text);
}
.analytics-item small {
  display: block;
  margin-top: 4px;
  color: #8d96a5;
}

.lang-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 20px 8px;
  margin: 0 auto;
  max-width: 100%;
  font-size: 13px;
  color: var(--muted, #6b7280);
}
.lang-switcher label {
  font-weight: 500;
  white-space: nowrap;
}
.lang-switcher select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 6px 28px 6px 12px;
  font-size: 13px;
  color: var(--text, #111827);
  cursor: pointer;
  min-width: 140px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.lang-switcher select:focus {
  outline: none;
  border-color: var(--primary, #4f46e5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
