/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: '72 Brand', 'Segoe UI', Arial, sans-serif;
  background: #f4f6f8;
  color: #223548;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────── */
header {
  background: #00144A;
  border-bottom: 3px solid #5D36FF;
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 24px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.header-icon {
  font-size: 28px;
  color: #F0AB00;
  font-weight: 900;
  line-height: 1;
}
.header-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.header-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}

/* ── Main layout ───────────────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 8px;
  padding: 24px 28px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: #00144A;
  margin-bottom: 18px;
}

/* ── Create form ───────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-url  { flex: 1 1 340px; }
.field-slug { flex: 1 1 220px; }
.field-btn  { flex: 0 0 auto; }

label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4D647C;
}
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: #9aafbf; }

input[type="url"],
input[type="text"] {
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: #223548;
  transition: border-color .15s;
  background: #fff;
  width: 100%;
}
input:focus { outline: none; border-color: #5D36FF; }
input::placeholder { color: #b0bec5; }

.slug-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  height: 40px;
  overflow: hidden;
  transition: border-color .15s;
}
.slug-wrap:focus-within { border-color: #5D36FF; }
.slug-prefix {
  padding: 0 10px;
  font-size: 12px;
  color: #9aafbf;
  background: #f4f6f8;
  border-right: 1.5px solid #d0d7de;
  white-space: nowrap;
  height: 100%;
  display: flex;
  align-items: center;
  user-select: none;
}
.slug-wrap input {
  border: none;
  border-radius: 0;
  height: 100%;
  flex: 1;
  min-width: 0;
}
.slug-wrap input:focus { outline: none; border-color: transparent; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  height: 40px;
  padding: 0 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: #5D36FF; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4a28e0; }

.btn-copy {
  background: #e8eeff;
  color: #3020a0;
  font-size: 12px;
  height: 32px;
  padding: 0 14px;
}
.btn-copy:hover { background: #d0d8ff; }

.btn-delete {
  background: none;
  color: #cc3333;
  font-size: 13px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #ecc;
  border-radius: 5px;
  font-weight: 600;
}
.btn-delete:hover { background: #fff0f0; }

.btn-edit {
  background: none;
  color: #4D647C;
  font-size: 12px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #d0d7de;
  border-radius: 5px;
  font-weight: 600;
}
.btn-edit:hover { background: #f4f6f8; }

/* ── Error / success ───────────────────────────────────────────── */
.error-msg {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fff0f0;
  border: 1px solid #f5c0c0;
  border-radius: 6px;
  font-size: 13px;
  color: #cc2222;
}
.success-toast {
  margin-top: 16px;
  padding: 14px 18px;
  background: #f0f4ff;
  border: 1px solid #c8d4ff;
  border-radius: 6px;
}
.success-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.success-label { font-size: 12px; font-weight: 700; color: #3020a0; text-transform: uppercase; letter-spacing: .08em; }
.success-link { font-size: 15px; font-weight: 700; color: #5D36FF; text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.success-link:hover { text-decoration: underline; }

/* ── Links section ─────────────────────────────────────────────── */
.links-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.links-header h2 { margin-bottom: 0; }
.badge {
  background: #e8eeff;
  color: #3020a0;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
}
.empty-state {
  text-align: center;
  padding: 40px 0;
  color: #9aafbf;
  font-size: 14px;
}

/* ── Table ─────────────────────────────────────────────────────── */
#linksTableWrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead tr {
  border-bottom: 2px solid #e8eaed;
}
th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #4D647C;
  padding: 8px 10px;
}
td {
  padding: 11px 10px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbff; }

.col-clicks { width: 70px; text-align: right; }
.col-date   { width: 110px; }
.col-actions { width: 110px; text-align: right; }

td.col-clicks { text-align: right; font-variant-numeric: tabular-nums; color: #4D647C; }
td.col-date   { color: #9aafbf; font-size: 12px; }
td.col-actions { white-space: nowrap; }

.short-link {
  font-weight: 700;
  color: #5D36FF;
  text-decoration: none;
  cursor: pointer;
}
.short-link:hover { text-decoration: underline; }

.dest-url {
  color: #4D647C;
  font-size: 12px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ── Domain picker ─────────────────────────────────────────────── */
.publish-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.publish-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4D647C;
  white-space: nowrap;
  padding-top: 10px;
}
.domain-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.chip-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.domain-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid #d0d7de;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #4D647C;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
}
.domain-chip:hover { border-color: #5D36FF; color: #5D36FF; }
.domain-chip.active {
  border-color: #5D36FF;
  background: #eeeaff;
  color: #3a1fcc;
}
.domain-chip .chip-check {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  flex-shrink: 0;
}
.domain-chip.active .chip-check::after { content: '✓'; }

.sub-input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  height: 32px;
  overflow: hidden;
  transition: border-color .15s;
  background: #fff;
}
.sub-input-wrap:focus-within { border-color: #5D36FF; }
.sub-input {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  color: #223548;
  padding: 0 8px;
  height: 100%;
  width: 130px;
  background: transparent;
}
.sub-suffix {
  font-size: 12px;
  color: #9aafbf;
  background: #f4f6f8;
  border-left: 1.5px solid #d0d7de;
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  user-select: none;
}
.dd-sub { color: #0a8a6e; }

/* ── URL input wrapper + dropdown ──────────────────────────────── */
.url-wrap {
  position: relative;
}
.url-wrap input {
  width: 100%;
}
.url-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1.5px solid #5D36FF;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 100;
  list-style: none;
  padding: 4px 0;
  margin: 0;
}
.url-dropdown li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.url-dropdown li:hover { background: #f4f6ff; }
.url-dropdown li .dd-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #9aafbf;
}
.url-dropdown li .dd-url {
  color: #223548;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.url-dropdown li .dd-short {
  color: #5D36FF;
  font-size: 12px;
  font-weight: 700;
}

/* ── Sites directory ───────────────────────────────────────────── */
.sites-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.site-group {
  flex: 1 1 200px;
  min-width: 0;
}
.site-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #4D647C;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid #5D36FF;
  display: inline-block;
}
.site-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f2f5;
  text-decoration: none;
  gap: 12px;
}
.site-row:last-child { border-bottom: none; }
.site-row:hover .site-url { color: #5D36FF; }
.site-url {
  font-size: 13px;
  font-weight: 600;
  color: #223548;
  transition: color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-desc {
  font-size: 11px;
  color: #9aafbf;
  white-space: nowrap;
}

/* ── Copy toast ────────────────────────────────────────────────── */
.copy-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #00144A;
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 999;
}
.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 16px 12px 40px; }
  .card { padding: 18px 16px; }
  .col-date, th.col-date { display: none; }
}
