/* MMO Links — giao diện tím / hồng / cam */
:root {
  --bg: #f3f4fa;
  --card: #ffffff;
  --ink: #1f2240;
  --muted: #6b7190;
  --line: #e3e6f0;
  --field: #eef1f8;
  --field-line: #dde2ee;
  --brand: #8b3cf0;
  --brand-dark: #6d28d9;
  --pink: #e0479e;
  --soft: #f6effe;
  --soft-line: #e4cff9;
  --orange: #f59e0b;
  --orange-dark: #d97706;
  --danger: #d9465a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 34, 64, .04), 0 10px 30px rgba(31, 34, 64, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 14px; z-index: 0;
  background: linear-gradient(180deg, #f5ead8, transparent);
}
a { color: var(--brand); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; word-break: break-all; }

.wrap { position: relative; max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------- Thanh trên ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; flex-wrap: wrap; }
.logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--pink));
  display: grid; place-items: center; color: #fff; font-weight: 800; letter-spacing: .02em;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Thẻ ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 32px; margin-bottom: 22px;
}
.card h2 { font-size: 16px; margin: 0 0 18px; }
.title-lg {
  font-size: 24px !important; font-weight: 800; margin-bottom: 22px !important;
  background: linear-gradient(90deg, var(--brand), #a234d6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.form-card { max-width: 700px; margin-left: auto; margin-right: auto; }
@media (max-width: 640px) { .card { padding: 20px 16px; } }

/* ---------- Form ---------- */
.field { margin-bottom: 18px; }
label { display: block; font-size: 13.5px; font-weight: 600; color: #4a4f6a; margin-bottom: 7px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }

input, select, textarea {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--field-line); border-radius: 10px;
  background: var(--field); color: var(--ink);
  font-size: 14.5px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: #9aa1b8; }
input:focus, select:focus, textarea:focus {
  outline: none; background: #fff; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(139, 60, 240, .15);
}
input:disabled { opacity: .55; }

.url-preview {
  margin-top: 10px; padding: 8px 14px;
  background: var(--soft); border: 1px solid var(--soft-line); border-radius: 8px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
  color: #7c2fd0; word-break: break-all;
}

.upload-row { display: flex; gap: 10px; }
.upload-row input { flex: 1; min-width: 0; }
.btn-upload {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap;
  padding: 0 18px; border: 1.5px dashed #c9a8f3; border-radius: 10px;
  color: var(--brand); font-weight: 700; font-size: 14px; cursor: pointer; background: #fff;
}
.btn-upload:hover { background: var(--soft); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border: none; border-radius: 10px;
  background: var(--brand); color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: transform .08s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-lg { padding: 13px 26px; font-size: 15.5px; border-radius: 12px; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-grad { background: linear-gradient(90deg, #8b3cf0, #e0479e); box-shadow: 0 6px 18px rgba(176, 64, 214, .28); }
.btn-amber { background: linear-gradient(180deg, var(--orange), var(--orange-dark)); color: #fff; box-shadow: 0 4px 12px rgba(217, 119, 6, .25); }
.btn-ghost { background: #fff; color: #4a4f6a; border: 1px solid var(--line); }
.btn-ghost:hover { background: #f6f7fc; filter: none; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #f1d3d8; }
.btn-danger:hover { background: #fdf2f4; filter: none; }
.icon-btn {
  width: 38px; height: 34px; padding: 0; border-radius: 8px; font-size: 15px;
  background: #fff; border: 1px solid var(--soft-line); color: #5b4b8a;
}
.icon-btn.del { border-color: var(--line); color: #9aa1b8; }
.icon-btn:hover { background: var(--soft); filter: none; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }

/* ---------- Bảng ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td .slug, .slug { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
td .dest { color: var(--muted); font-size: 12.5px; word-break: break-all; max-width: 300px; display: inline-block; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; margin-top: 4px; }
.pill-green { background: #e7f6ee; color: #1f7a4d; }
.pill-amber { background: #fdf1d8; color: #9a6206; }
.pill-blue { background: var(--soft); color: #7c2fd0; margin-left: 4px; }

.msg { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }
.msg-err { background: #fdf2f4; color: var(--danger); border: 1px solid #f1d3d8; }
.msg-ok { background: #edf8f2; color: #1f7a4d; border: 1px solid #cdebd9; }

/* ---------- Thống kê ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 26px; font-weight: 800; color: var(--brand-dark); word-break: break-all; }
.stat .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--brand), var(--pink)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar:hover { filter: brightness(1.15); }
.breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .breakdown { grid-template-columns: 1fr; } }
.breakdown .line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.breakdown .line span:last-child { font-weight: 700; }
.back { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 14px; }
.back:hover { color: var(--brand); }
.steps { margin: 10px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.8; }

/* ---------- Cửa sổ "Link kênh" (kiểu ảnh 2) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; padding: 16px;
  background: rgba(40, 38, 70, .45); backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.modal {
  width: 100%; max-width: 720px; max-height: calc(100vh - 32px); overflow: auto;
  background: #fff; border-radius: 22px; box-shadow: 0 24px 70px rgba(20, 18, 50, .3);
}
.modal-head { display: flex; align-items: center; gap: 14px; padding: 22px 26px; background: #f3f4fa; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; font-weight: 800; }
.modal-icon {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: #fdecc8; display: grid; place-items: center; font-size: 22px;
}
.modal-section { margin: 0; padding: 18px 26px; background: #f3f4fa; border-bottom: 1px solid var(--line); }
.modal-list { padding: 18px 26px 24px; }
.section-label { font-size: 12px; font-weight: 800; letter-spacing: .06em; color: #8a90aa; margin-bottom: 10px; text-transform: uppercase; }
.modal-section label { font-weight: 500; color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.modal-section input, .modal-section select { background: #e9ebf7; border-color: #d7d2f2; }
.ch-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.ch-row .field { min-width: 180px; margin-bottom: 10px; }
.ch-row .btn-amber { padding: 12px 22px; font-size: 15px; }
.ch-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px 9px 14px; margin-bottom: 8px;
  background: #ebedf8; border: 1px solid #dfe2f2; border-radius: 10px;
}
.ch-item form { margin: 0; }
.ch-url { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: #3c4060; word-break: break-all; }
.ch-clicks { font-size: 12px; color: var(--muted); white-space: nowrap; margin-right: 4px; }

/* ---------- Xem trước ảnh & thẻ share ---------- */
[hidden] { display: none !important; }
.thumb-wrap { display: flex; gap: 14px; align-items: center; margin-top: 10px; padding: 10px;
  background: var(--soft); border: 1px solid var(--soft-line); border-radius: 12px; }
.thumb-wrap img { width: 150px; height: 79px; object-fit: cover; border-radius: 8px; background: #fff; flex: none; border: 1px solid var(--line); }
.thumb-meta { min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.thumb-name { font-size: 13px; font-weight: 600; color: #4a4f6a; word-break: break-all; }

.share-card { border: 1px solid #dadde1; border-radius: 10px; overflow: hidden; background: #fff; max-width: 520px; }
.sc-img { position: relative; aspect-ratio: 1.91 / 1; background: #eef0f4; display: grid; place-items: center; }
.sc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-noimg { color: #8a8f9c; font-size: 13px; padding: 0 20px; text-align: center; }
.sc-body { padding: 10px 12px 12px; background: #f0f2f5; border-top: 1px solid #dadde1; }
.sc-host { font-size: 12px; color: #65676b; letter-spacing: .02em; text-transform: uppercase; }
.sc-title { font-size: 16px; font-weight: 700; color: #050505; line-height: 1.3; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sc-desc { font-size: 14px; color: #65676b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .thumb-wrap img { width: 110px; height: 58px; } }

/* ---------- Tình trạng hệ thống ---------- */
.pill-red { background: #fde8eb; color: #b42335; }
.health-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 8px; border-radius: 10px; border: 1px solid var(--line); font-size: 13.5px; }
.health-error { background: #fdf2f4; border-color: #f1d3d8; }
.health-warn { background: #fdf8ec; border-color: #f3e2b8; }
.health-ok { background: #f4fbf7; border-color: #d4eddf; }

/* ---------- v3: bám sát ảnh mẫu ---------- */
.title-lg { font-family: "Nunito", sans-serif; font-weight: 900 !important; letter-spacing: -.01em; }
.btn, label, .section-label, .modal-head h2 { font-family: "Nunito", sans-serif; }
.btn i, .btn-upload i { font-size: .95em; }
.btn-grad { padding: 14px 28px; border-radius: 12px; font-weight: 800; }

/* Dòng link xem trước: chọn tên miền ngay trong dòng, như ảnh 1 */
.url-preview { display: flex; align-items: center; gap: 0; flex-wrap: wrap; padding: 7px 12px; }
.url-preview span { font-family: ui-monospace, Menlo, Consolas, monospace; }
.url-domain {
  width: auto; max-width: 100%; padding: 0 18px 0 0; margin: 0; border: none; background: transparent; box-shadow: none;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; color: #7c2fd0; cursor: pointer;
  appearance: auto;
}
.url-domain:focus { outline: none; box-shadow: none; background: transparent; }

/* Nút thêm UTM: dòng chữ nhỏ thay vì nút to */
.utm-toggle { margin: -6px 0 18px; }
.utm-toggle > summary { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--brand); cursor: pointer; }
.utm-toggle[open] > summary { margin-bottom: 12px; }
.utm-toggle > summary i { font-size: 11px; }

/* Cửa sổ kiểu ảnh 2 */
.modal-icon { background: #fdecc8; color: #d97706; font-size: 20px; }
.modal-head { flex-wrap: wrap; }
.icon-btn { font-size: 14px; }
.icon-btn i { color: #5b4b8a; }
.icon-btn.del i { color: #9aa1b8; }
.btn-amber i { color: #fff; }
.section-label .btn { text-transform: none; letter-spacing: 0; font-weight: 700; }

/* ---------- v4: form tạo link trong modal ---------- */
.create-modal { max-width: 640px; }
.create-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px 28px 4px; }
.create-body { padding: 14px 28px 26px; }
@media (max-width: 640px) { .create-head { padding: 18px 16px 4px; } .create-body { padding: 12px 16px 20px; } }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.list-head .btn-grad { padding: 11px 20px; }
.row-actions { flex-wrap: nowrap; align-items: center; }
.row-actions .btn-amber { padding: 7px 12px; }
.btn { white-space: nowrap; }

/* ---------- Lấy Link Bắn — Material, theo tông MMO Links ---------- */
.m3 {
  --md-primary: #8b3cf0;
  --md-primary-dark: #6d28d9;
  --md-pink: #e0479e;
  --md-grad: linear-gradient(90deg, #8b3cf0, #e0479e);
  --md-primary-soft: #f6effe;
  --md-primary-line: #e4cff9;
  --md-surface: #ffffff;
  --md-surface-2: #f7f6fc;
  --md-on-surface: #1f2240;
  --md-muted: #6b7190;
  --md-faint: #9aa1b8;
  --md-line: #e7e8f2;
  --md-outline: #cfd2e3;
  --md-error: #d9465a;
  --md-ease: cubic-bezier(.2, 0, 0, 1);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--md-on-surface);
  -webkit-font-smoothing: antialiased;
}
.m3 *, .m3 *::before, .m3 *::after { box-sizing: border-box; }
.ms {
  font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal;
  font-size: 22px; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap;
  display: inline-block; direction: ltr; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; user-select: none; flex: none;
}

/* Nền mờ + hộp thoại */
.m3-scrim {
  position: fixed; inset: 0; z-index: 50; padding: 24px;
  background: rgba(31, 34, 64, .42); backdrop-filter: blur(4px);
  display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  animation: m3-fade .2s linear;
}
.m3-dialog {
  width: 100%; max-width: 620px; min-width: 0; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--md-surface); border-radius: 24px;
  box-shadow: 0 24px 64px rgba(31, 34, 64, .28), 0 2px 6px rgba(31, 34, 64, .08);
  animation: m3-enter .3s var(--md-ease);
}
@keyframes m3-fade { from { opacity: 0; } }
@keyframes m3-enter { from { opacity: 0; transform: translateY(12px) scale(.98); } }

.m3-dlg-head { display: flex; align-items: center; gap: 14px; padding: 22px 16px 18px 24px; flex: none; }
.m3-dlg-icon {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 24px;
  background: var(--md-grad); color: #fff; box-shadow: 0 6px 16px rgba(176, 64, 214, .3);
}
.m3-dlg-titles { flex: 1; min-width: 0; }
.m3-headline { margin: 0; font: 800 20px/26px "Nunito", sans-serif; color: var(--md-on-surface); }
.m3-supporting { margin: 2px 0 0; font-size: 13.5px; line-height: 20px; color: var(--md-muted); overflow-wrap: anywhere; }
.m3-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--md-primary); }
.m3-dlg-head > .m3-icon-btn { align-self: flex-start; }

.m3-dlg-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.m3-divider { height: 1px; background: var(--md-line); }

/* Form tạo link: nền xám tím rất nhạt để tách khỏi danh sách */
.m3-form { margin: 0; padding: 22px 24px 20px; background: var(--md-surface-2); border-top: 1px solid var(--md-line); }
.m3-form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.m3-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* Ô nhập có viền, nhãn nằm trên viền (outlined text field) */
.m3-field {
  position: relative; display: flex; align-items: center; height: 52px; min-width: 0;
  border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--md-outline); transition: box-shadow .15s;
}
.m3-field:hover { box-shadow: inset 0 0 0 1px #a9aec8; }
.m3-field:focus-within { box-shadow: inset 0 0 0 2px var(--md-primary), 0 0 0 4px rgba(139, 60, 240, .12); }
.m3-field > label {
  position: absolute; top: -9px; left: 12px; z-index: 1; margin: 0; padding: 0 5px;
  background: linear-gradient(var(--md-surface-2) 50%, #fff 50%); color: var(--md-muted);
  font: 700 12px/18px "Nunito", sans-serif; pointer-events: none;
}
.m3-field:focus-within > label { color: var(--md-primary); }
.m3-field input, .m3-field select {
  flex: 1; min-width: 0; height: 100%; margin: 0; border: 0; border-radius: 12px; outline: 0; box-shadow: none !important;
  background: transparent !important; color: var(--md-on-surface); font: 600 15px/22px "Nunito", sans-serif;
}
.m3-field-qty { flex: none; width: 148px; padding: 0 4px; }
.m3-field-qty input { text-align: center; padding: 0; font-weight: 800; font-size: 17px; -moz-appearance: textfield; }
.m3-field-qty input::-webkit-outer-spin-button, .m3-field-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.m3-field-select { flex: 1 1 220px; }
.m3-field-select select { appearance: none; -webkit-appearance: none; padding: 0 42px 0 16px; cursor: pointer; text-overflow: ellipsis; }
.m3-field-trail { position: absolute; right: 12px; color: var(--md-muted); pointer-events: none; }

/* Chip chọn nhanh */
.m3-chip-set { display: flex; flex-wrap: wrap; gap: 8px; }
.m3-chip {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 4px;
  height: 34px; min-width: 46px; justify-content: center; padding: 0 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--md-outline); background: #fff; color: #4a4f6a;
  font: 700 14px/20px "Nunito", sans-serif; transition: background .2s, color .2s, border-color .2s;
}
.m3-chip .ms { display: none; font-size: 18px; margin-left: -4px; }
.m3-chip.on { background: var(--md-primary-soft); border-color: var(--md-primary-line); color: var(--md-primary-dark); }
.m3-chip.on .ms { display: inline-block; }

.m3-help, .m3-error { display: flex; gap: 6px; align-items: flex-start; margin: 14px 0 0; font-size: 12.5px; line-height: 18px; color: var(--md-faint); }
.m3-error { color: var(--md-error); font-size: 13.5px; font-weight: 600; }
.m3-error .ms { font-size: 19px; }

/* Danh sách link bắn */
.m3-list-wrap { padding: 4px 16px 16px; }
.m3-list-head {
  position: sticky; top: 0; z-index: 2; background: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 12px 4px 10px 8px; min-height: 56px;
}
.m3-title-sm { margin: 0; display: flex; align-items: center; gap: 8px; font: 800 12px/18px "Nunito", sans-serif; letter-spacing: .06em; text-transform: uppercase; color: #8a90aa; }
.m3-count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; background: var(--md-primary-soft); color: var(--md-primary-dark); font-size: 12px; letter-spacing: 0; }
.m3-list-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.m3-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.m3-list-item {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 8px 6px 8px 12px; border-radius: 14px; background: #fff; border: 1px solid var(--md-line);
  transition: border-color .15s, box-shadow .15s;
}
.m3-list-item:hover { border-color: #d9dbea; box-shadow: 0 4px 14px rgba(31, 34, 64, .06); }
.m3-list-item.is-new { background: #fcf9ff; border-color: var(--md-primary-line); }
.m3-list-item.is-new::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--md-grad); }
.m3-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: #f1f2f8; color: var(--md-muted); font: 800 13px/1 "Nunito", sans-serif;
}
.m3-list-item.is-new .m3-avatar { background: var(--md-primary-soft); color: var(--md-primary-dark); }
.m3-li-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m3-li-headline {
  font: 600 14px/20px ui-monospace, Menlo, Consolas, monospace; color: var(--md-on-surface);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m3-li-headline:hover { color: var(--md-primary); text-decoration: underline; }
.m3-li-supporting { font-size: 12.5px; line-height: 18px; color: var(--md-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m3-badge { flex: none; padding: 2px 9px; border-radius: 999px; background: #fde7f3; color: #c0307f; font: 800 11.5px/16px "Nunito", sans-serif; }
.m3-clicks {
  flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 4px 8px; border-radius: 8px;
  color: var(--md-muted); text-decoration: none; font: 700 13px/18px "Nunito", sans-serif;
}
.m3-clicks .ms { font-size: 17px; }
.m3-clicks:hover { background: var(--md-primary-soft); color: var(--md-primary-dark); }
.m3-li-trail { flex: none; display: flex; align-items: center; }
.m3-li-trail form { margin: 0; }

.m3-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 24px 28px; color: var(--md-muted); }
.m3-empty > .ms { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--md-primary-soft); color: var(--md-primary); margin-bottom: 12px; font-size: 26px; }
.m3-empty p { margin: 0; }
.m3-empty-title { font-size: 15px; line-height: 22px; font-weight: 800; color: var(--md-on-surface); }
.m3-empty-body { font-size: 13.5px; line-height: 20px; margin-top: 2px !important; }

/* Nút */
.m3-btn {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none; white-space: nowrap;
  font: 800 14.5px/20px "Nunito", sans-serif; transition: box-shadow .2s, transform .08s;
}
.m3-btn:active { transform: translateY(1px); }
.m3-btn .ms { font-size: 20px; margin-left: -4px; }
.m3-btn b { font-weight: 900; }
.m3-filled { background: var(--md-grad); color: #fff; box-shadow: 0 6px 18px rgba(176, 64, 214, .28); }
.m3-filled:hover { box-shadow: 0 8px 22px rgba(176, 64, 214, .38); }
.m3-filled:disabled { opacity: .7; cursor: default; transform: none; }
.m3-tonal { background: var(--md-primary-soft); color: var(--md-primary-dark); }
.m3-text { background: transparent; color: var(--md-primary); }
.m3-btn.m3-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.m3-btn.m3-sm .ms { font-size: 17px; }
.m3-btn.copied { background: #e7f6ee; color: #1f7a4d; }

/* Nút icon tròn */
.m3-icon-btn {
  position: relative; overflow: hidden; display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--md-muted); text-decoration: none;
}
.m3-icon-btn .ms { font-size: 20px; }
.m3-icon-btn.m3-sm { width: 36px; height: 36px; color: #5b4b8a; }
.m3-icon-btn.copied { color: #1f7a4d; }
.m3-icon-btn.m3-danger:hover { color: var(--md-error); }

/* Lớp phủ khi rê chuột / bấm (state layer) */
.m3-btn::after, .m3-icon-btn::after, .m3-chip::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: 0;
  transition: opacity .15s; pointer-events: none;
}
.m3-btn:hover::after, .m3-icon-btn:hover::after, .m3-chip:hover::after { opacity: .07; }
.m3-btn:active::after, .m3-icon-btn:active::after, .m3-chip:active::after { opacity: .12; }
.m3-filled::after { background: #fff; }
.m3-btn:disabled::after { display: none; }
.m3-btn:focus-visible, .m3-icon-btn:focus-visible, .m3-chip:focus-visible { outline: 3px solid rgba(139, 60, 240, .35); outline-offset: 2px; }

/* Vòng xoay khi đang tạo */
.m3-spinner { width: 18px; height: 18px; margin-left: -4px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: m3-spin .8s linear infinite; }
@keyframes m3-spin { to { transform: rotate(360deg); } }

/* Snackbar (thông báo chép link) */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; min-width: 240px; max-width: 520px; text-align: center;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 12px; background: #1f2240; color: #fff;
  font: 700 14px/20px "Nunito", system-ui, sans-serif;
  box-shadow: 0 10px 30px rgba(20, 18, 50, .3);
  transition: opacity .15s linear, transform .3s cubic-bezier(.2, 0, 0, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.no-scroll { overflow: hidden; }

/* Các modal khác không tràn ngang trên điện thoại */
.modal-backdrop { grid-template-columns: minmax(0, 1fr); justify-items: center; }
.modal { min-width: 0; }

/* Điện thoại: hộp thoại dạng tấm trượt từ dưới lên */
@media (max-width: 600px) {
  .m3-scrim { padding: 0; align-items: end; }
  .m3-dialog { max-width: none; max-height: 94vh; max-height: 94dvh; border-radius: 24px 24px 0 0; animation-name: m3-enter-up; }
  @keyframes m3-enter-up { from { transform: translateY(40px); opacity: 0; } }
  .m3-dlg-head { padding: 18px 8px 14px 16px; }
  .m3-dlg-icon { width: 40px; height: 40px; border-radius: 12px; }
  .m3-form { padding: 20px 16px 16px; }
  .m3-field-qty { width: 132px; }
  .m3-field-select { flex-basis: 150px; }
  .m3-form-actions .m3-btn { flex: 1 1 100%; }
  .m3-list-wrap { padding: 4px 10px calc(16px + env(safe-area-inset-bottom)); }
  .m3-li-supporting, .m3-badge { display: none; }   /* vạch màu bên trái đã đánh dấu link mới */
  .m3-list-item { gap: 10px; padding-left: 10px; }
  .m3-li-trail .m3-icon-btn { width: 34px; height: 34px; }
  .toast { left: 16px; right: 16px; bottom: 20px; min-width: 0; max-width: none; transform: translateY(16px); }
  .toast.show { transform: none; }
}

/* ======================================================================
   Trang chính (index) — cùng phong cách với modal Lấy Link Bắn
   ====================================================================== */
.m3-page { position: relative; }
.m3-page [hidden] { display: none !important; }

/* Thanh đầu trang */
.m3-appbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.m3-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.m3-brand .logo { width: 44px; height: 44px; border-radius: 13px; box-shadow: 0 6px 16px rgba(176, 64, 214, .3); }
.m3-brand-text { min-width: 0; }
.m3-brand-text h1 { margin: 0; font: 900 20px/26px "Nunito", sans-serif; color: var(--md-on-surface); }
.m3-brand-text p { margin: 0; font-size: 13px; color: var(--md-muted); }
.m3-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.m3-nav-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border: 0; border-radius: 999px; background: transparent; color: #4a4f6a; cursor: pointer; text-decoration: none;
  font: 700 13.5px/20px "Nunito", sans-serif;
}
.m3-nav-btn .ms { font-size: 20px; color: var(--md-muted); }
.m3-nav-btn:hover { background: rgba(139, 60, 240, .07); color: var(--md-primary-dark); }
.m3-nav-btn:hover .ms { color: var(--md-primary); }
.m3-nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--md-error); color: #fff; font: 800 11px/18px "Nunito", sans-serif; text-align: center;
}
@media (max-width: 760px) {
  .m3-nav-badge { position: absolute; top: 2px; right: -2px; border: 2px solid var(--bg); }
}
@media (max-width: 600px) {
  .m3-appbar { flex-wrap: nowrap; margin-bottom: 16px; }
  .m3-brand .logo { width: 40px; height: 40px; border-radius: 12px; }
  .m3-brand-text h1 { font-size: 18px; }
  .m3-nav { flex-wrap: nowrap; gap: 0; }
  .m3-nav .m3-nav-btn { width: 36px; height: 36px; }
  .m3-card-head .m3-card-tools { flex: 1 1 100%; }
  .m3-hostpart { display: none; }   /* trên điện thoại chỉ hiện /slug */
}

.m3-banner {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; padding: 12px 16px; border-radius: 14px;
  background: #fdf2f4; color: var(--md-error); border: 1px solid #f1d3d8; font-size: 14px; font-weight: 600;
}
.m3-banner .ms { font-size: 20px; }

/* Ô số liệu tổng */
.m3-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.m3-stat {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 18px;
  background: #fff; border: 1px solid var(--md-line); box-shadow: 0 1px 2px rgba(31, 34, 64, .04);
}
.m3-stat-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--md-primary-soft); color: var(--md-primary); font-size: 22px; }
.m3-stat b { display: block; font: 900 22px/26px "Nunito", sans-serif; color: var(--md-on-surface); }
.m3-stat span:not(.ms) { font-size: 12.5px; color: var(--md-muted); font-weight: 600; }

/* Thẻ danh sách link */
.m3-card { background: #fff; border: 1px solid var(--md-line); border-radius: 22px; box-shadow: 0 1px 2px rgba(31, 34, 64, .04), 0 10px 30px rgba(31, 34, 64, .05); padding: 8px 12px 12px; margin-bottom: 24px; }
.m3-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 8px 14px; }
.m3-card-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.m3-search {
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 6px 0 12px; margin: 0; flex: 0 1 280px; min-width: 0;
  border-radius: 999px; background: var(--md-surface-2); border: 1px solid var(--md-line); transition: box-shadow .15s, background .15s;
}
.m3-search .ms { color: var(--md-muted); font-size: 20px; }
.m3-search:focus-within { background: #fff; box-shadow: 0 0 0 2px var(--md-primary); border-color: transparent; }
.m3-search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent !important; box-shadow: none !important; font: 600 14px "Nunito", sans-serif; }

.m3-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.m3-link {
  display: flex; align-items: center; gap: 14px; padding: 12px 10px 12px 12px; border-radius: 16px;
  border: 1px solid var(--md-line); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.m3-link:hover { border-color: #d9dbea; box-shadow: 0 4px 14px rgba(31, 34, 64, .06); }
.m3-thumb {
  position: relative; flex: none; width: 56px; height: 56px; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center; background: var(--md-primary-soft); color: var(--md-primary);
}
.m3-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.m3-link-main { flex: 1; min-width: 0; }
.m3-link-slug {
  display: block; font: 700 14.5px/20px ui-monospace, Menlo, Consolas, monospace; color: var(--md-primary-dark);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m3-link-slug:hover { text-decoration: underline; }
.m3-link-dest { margin-top: 1px; font-size: 13.5px; line-height: 19px; color: #4a4f6a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m3-link-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.m3-link-tags .pill { margin: 0; }
.m3-tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font: 800 11.5px/18px "Nunito", sans-serif; }
.tag-green { background: #e7f6ee; color: #1f7a4d; }
.tag-amber { background: #fdf1d8; color: #9a6206; }
.tag-purple { background: var(--md-primary-soft); color: var(--md-primary-dark); }
.m3-link-host { font-size: 12px; color: var(--md-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.m3-link-clicks {
  flex: none; display: flex; flex-direction: column; align-items: center; min-width: 64px; padding: 6px 10px; border-radius: 12px;
  text-decoration: none; color: var(--md-on-surface);
}
.m3-link-clicks b { font: 900 18px/22px "Nunito", sans-serif; }
.m3-link-clicks span { font-size: 11.5px; color: var(--md-faint); font-weight: 700; }
.m3-link-clicks:hover { background: var(--md-primary-soft); color: var(--md-primary-dark); }
.m3-link-actions { flex: none; display: flex; align-items: center; gap: 2px; }
.m3-link-actions form { margin: 0; }
.m3-link-actions .m3-btn { margin: 0 4px; }

/* Thanh nút đáy của hộp thoại */
.m3-dlg-actions { flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--md-line); background: #fff; }

/* Modal Tạo Link Mới */
.create-dialog { max-width: 640px; }
.create-form { margin: 0; padding: 22px 24px 8px; background: var(--md-surface-2); border-top: 1px solid var(--md-line); min-height: 100%; }
.create-form .field { margin-bottom: 18px; }
.create-form label { font: 700 13px/18px "Nunito", sans-serif; color: #4a4f6a; margin-bottom: 7px; }
.create-form input:not([type=hidden]):not([type=file]), .create-form select:not(.url-domain) {
  height: 48px; padding: 0 16px; border-radius: 12px; background: #fff; border: 1px solid var(--md-outline); font: 600 14.5px "Nunito", sans-serif;
}
.create-form input:focus { border-color: var(--md-primary); box-shadow: 0 0 0 4px rgba(139, 60, 240, .12); }
.create-form .url-preview { border-radius: 10px; }
.create-form .btn-upload { border-radius: 12px; gap: 4px; }
.create-form .btn-upload .ms { font-size: 20px; }
.create-form .utm-toggle > summary { display: inline-flex; align-items: center; gap: 4px; }
.create-form .utm-toggle > summary .ms { font-size: 18px; transition: transform .2s; }
.create-form .utm-toggle[open] > summary .ms { transform: rotate(45deg); }
.create-form .thumb-wrap { background: #fff; }

/* Máy tính bảng / điện thoại */
@media (max-width: 760px) {
  .m3-nav-label { display: none; }
  .m3-nav-btn { width: 40px; padding: 0; justify-content: center; }
  .m3-link { flex-wrap: wrap; }
  .m3-link-main { flex-basis: calc(100% - 150px); }
  .m3-link-actions { flex-basis: 100%; justify-content: flex-end; padding-top: 8px; border-top: 1px dashed var(--md-line); }
  .m3-link-actions form { order: -1; margin-right: auto; }
}
@media (max-width: 600px) {
  .m3-brand-text p { display: none; }
  .m3-stats { gap: 8px; }
  .m3-stat { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border-radius: 16px; }
  .m3-stat-ic { width: 34px; height: 34px; font-size: 19px; border-radius: 10px; }
  .m3-stat b { font-size: 19px; line-height: 22px; }
  .m3-card { padding: 4px 8px 8px; border-radius: 18px; }
  .m3-search { flex: 1 1 100%; }
  .m3-card-tools .m3-filled { flex: 1 1 100%; }
  .m3-thumb { width: 44px; height: 44px; border-radius: 10px; }
  .m3-link { gap: 10px; padding: 10px; }
  .m3-link-main { flex-basis: calc(100% - 130px); }
  .m3-link-clicks { min-width: 52px; padding: 4px 6px; }
  .create-form { padding: 18px 16px 8px; }
  .m3-dlg-actions { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .m3-dlg-actions .m3-filled { flex: 1; }
}

/* ---------- Đồng hồ New York & Việt Nam ---------- */
.m3-clocks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.m3-clock {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-radius: 18px; border: 1px solid var(--md-line);
  transition: background .6s, color .6s;
}
.m3-clock.is-day { background: linear-gradient(135deg, #fff6e3 0%, #ffffff 70%); color: var(--md-on-surface); }
.m3-clock.is-night { background: linear-gradient(135deg, #1f2240 0%, #3a2a6e 100%); color: #fff; border-color: transparent; }
.m3-clock-ic {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 26px;
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}
.m3-clock.is-day .m3-clock-ic { background: #fde7b8; color: #d97706; }
.m3-clock.is-night .m3-clock-ic { background: rgba(255, 255, 255, .12); color: #c4b5fd; }
.m3-clock-body { min-width: 0; }
.m3-clock-city { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: 13px; line-height: 18px; }
.m3-clock-city b { font-weight: 800; }
.m3-clock-city span { opacity: .6; font-size: 12px; }
.m3-clock-time {
  display: block; font: 900 32px/38px "Nunito", sans-serif; letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
}
.m3-clock-time small { font-size: 18px; font-weight: 800; opacity: .55; margin-left: 1px; }
.m3-clock-date { font-size: 12.5px; line-height: 18px; opacity: .7; font-weight: 600; font-variant-numeric: tabular-nums; }
.m3-clock-diff { grid-column: 1 / -1; text-align: center; font-size: 12px; color: var(--md-faint); font-weight: 700; margin-top: -2px; }
.m3-clock-diff:empty { display: none; }

@media (max-width: 600px) {
  .m3-clocks { gap: 8px; }
  .m3-clock { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border-radius: 16px; }
  .m3-clock-ic { width: 34px; height: 34px; font-size: 19px; border-radius: 10px; }
  .m3-clock-city span { display: none; }
  .m3-clock-time { font-size: 26px; line-height: 30px; }
  .m3-clock-time small { font-size: 15px; }
  .m3-clock-date { font-size: 11.5px; }
}

/* ---------- Thay link hàng loạt ---------- */
.replace-dialog { max-width: 640px; }
.replace-dialog .m3-chip-set { margin-top: 0; }
.replace-dialog .m3-chip { margin: 0; font-size: 13.5px; }
.replace-dialog .m3-chip input { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.replace-dialog .m3-chip:focus-within { outline: 3px solid rgba(139, 60, 240, .35); outline-offset: 2px; }
.replace-dialog .m3-help { margin-top: 8px; }
.r-preview { margin: 4px 0 18px; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--md-line); }
.r-preview-empty { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13.5px; color: var(--md-faint); }
.r-preview-empty .ms { font-size: 18px; }
.r-none { color: #9a6206; }
.r-preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.r-preview-head b { font-size: 14.5px; font-weight: 800; color: var(--md-primary-dark); }
.r-preview-head span { font-size: 12.5px; color: var(--md-muted); font-weight: 600; }
.r-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.r-list li { display: grid; grid-template-columns: 1fr; gap: 1px; padding: 8px 10px; border-radius: 10px; background: var(--md-surface-2); font-size: 12.5px; min-width: 0; }
.r-slug { font: 700 13px/18px ui-monospace, Menlo, Consolas, monospace; color: var(--md-on-surface); }
.r-slug em { font: 800 10.5px/16px "Nunito", sans-serif; font-style: normal; padding: 0 6px; border-radius: 8px; background: var(--md-primary-soft); color: var(--md-primary-dark); margin-left: 4px; }
.r-old, .r-new { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.r-old { color: var(--md-faint); text-decoration: line-through; }
.r-new { color: #1f7a4d; font-weight: 700; }
.r-arrow { display: none; }
.r-more { margin: 8px 0 0; font-size: 12.5px; color: var(--md-muted); }
.r-warn { margin: 8px 0 0; font-size: 13px; color: var(--md-error); font-weight: 600; }
.m3-btn.m3-tonal { white-space: nowrap; }

/* Snackbar có nút Hoàn tác */
.toast.toast-action { display: flex; align-items: center; gap: 16px; pointer-events: auto; text-align: left; padding: 8px 8px 8px 18px; }
.toast-action span { flex: 1; }
.toast-btn { border: 0; background: transparent; color: #d8b4fe; font: 800 14px/20px "Nunito", sans-serif; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.toast-btn:hover { background: rgba(255, 255, 255, .08); }
@media (max-width: 600px) {
  .m3-card-tools .m3-tonal { flex: 1 1 auto; }
  .m3-card-tools .m3-filled { flex: 1 1 auto; }
}
