/* ============================================================
   NganLink.com — Design System
   ============================================================ */

/* ---------- Article body typography (SEO posts) ---------- */
.article-body { font-size: 17px; line-height: 1.75; color: #1e293b; }
.article-body > * + * { margin-top: 18px; }
.article-body h2 { font-size: 26px; letter-spacing: -.01em; margin-top: 38px; margin-bottom: 4px; }
.article-body h3 { font-size: 21px; margin-top: 28px; margin-bottom: 2px; }
.article-body p { margin-top: 16px; }
.article-body ul, .article-body ol { margin: 16px 0 16px 22px; }
.article-body li { margin: 8px 0; }
.article-body a { color: #4f46e5; text-decoration: underline; text-underline-offset: 2px; }
.article-body a:hover { text-decoration: none; }
.article-body img { border-radius: 12px; margin: 22px 0; }
.article-body blockquote {
  border-left: 4px solid #4f46e5; background: #f8fafc; margin: 22px 0;
  padding: 14px 20px; border-radius: 0 10px 10px 0; color: #475569; font-style: italic;
}
.article-body code { background: #f1f5f9; padding: 2px 7px; border-radius: 6px; font-size: 15px; }
.article-body table { margin: 22px 0; }
.article-body figure { margin: 22px 0; }
.article-body strong { color: #0f172a; }

:root {
  --brand:        #4f46e5;
  --brand-2:      #06b6d4;
  --brand-grad:   linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  --ink:          #0f172a;
  --ink-2:        #334155;
  --muted:        #64748b;
  --line:         #e2e8f0;
  --bg:           #f8fafc;
  --card:         #ffffff;
  --ok:           #16a34a;
  --warn:         #d97706;
  --danger:       #dc2626;
  --radius:       16px;
  --radius-sm:    10px;
  --shadow:       0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg:    0 20px 50px rgba(15,23,42,.12);
  --maxw:         1140px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 600; font-size: 15px;
  padding: 12px 22px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: .18s ease; white-space: nowrap; line-height: 1;
}
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(79,70,229,.4); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 21px; letter-spacing: -.02em; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand-grad);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 14px rgba(79,70,229,.35);
}
.brand .dot { color: var(--brand-2); }
.nav-links { display: flex; align-items: center; gap: 28px; }
.nav-links a { color: var(--ink-2); font-weight: 500; font-size: 15px; transition: .15s; }
.nav-links a:hover { color: var(--brand); }
.nav-actions { display: flex; align-items: center; gap: 14px; }

/* ---------- Language switcher ---------- */
.lang {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  background: #fff; font-weight: 600; font-size: 13px; color: var(--ink-2);
}
.lang:hover { border-color: var(--brand); }
.lang .flag { font-size: 16px; }

/* ---------- Language dropdown ---------- */
.lang-switch { position: relative; }
.lang-switch summary { list-style: none; user-select: none; }
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary .lang-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-switch summary svg { transition: transform .2s; color: var(--muted); }
.lang-switch[open] summary svg { transform: rotate(180deg); }
.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; min-width: 230px;
  max-height: 360px; overflow-y: auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
}
.lang-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap; transition: .12s;
}
.lang-item:hover { background: var(--bg); color: var(--brand); }
.lang-item.active { background: rgba(79,70,229,.1); color: var(--brand); font-weight: 700; }
.lang-item .flag { font-size: 16px; }
@media (max-width: 560px) {
  .lang-menu { grid-template-columns: 1fr; right: -10px; min-width: 180px; }
  .lang-switch summary .lang-name { display: none; }
}

/* ---------- Hero ---------- */
.hero { padding: 76px 0 56px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(700px 320px at 50% -10%, rgba(79,70,229,.14), transparent 70%),
    radial-gradient(500px 300px at 90% 10%, rgba(6,182,212,.12), transparent 70%);
}
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; font-size: 13px; font-weight: 600; color: var(--brand);
  box-shadow: var(--shadow); margin-bottom: 22px;
}
.hero h1 { font-size: clamp(34px, 5vw, 56px); line-height: 1.1; letter-spacing: -.03em; font-weight: 800; }
.hero h1 .grad { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p.sub { font-size: clamp(16px, 2vw, 20px); color: var(--muted); max-width: 620px; margin: 18px auto 0; }

/* ---------- Create form ---------- */
.create-card {
  max-width: 720px; margin: 36px auto 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 22px;
}
.create-row { display: flex; gap: 12px; }
.create-row .field { flex: 1; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 14px; background: #fff; }
.create-row .field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.create-row .field svg { color: var(--muted); flex-shrink: 0; }
.create-row input { flex: 1; border: 0; outline: 0; font-family: var(--font); font-size: 16px; padding: 15px 0; background: transparent; color: var(--ink); }
.create-opts { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.alias { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.alias .pref { color: var(--ink-2); font-weight: 600; }
.alias input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: var(--font); font-size: 14px; width: 130px; outline: 0; }
.alias input:focus { border-color: var(--brand); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ---------- Result ---------- */
.result { max-width: 720px; margin: 18px auto 0; display: none; }
.result.show { display: block; animation: pop .35s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 14px;
}
.result-card .lbl { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.result-card.short .lbl { color: var(--brand); }
.result-card.stats .lbl { color: var(--warn); }
.copy-row { display: flex; gap: 10px; align-items: center; }
.copy-row .url { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 16px; font-family: 'SF Mono', ui-monospace, monospace; font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.hint.warn { color: var(--warn); }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section.alt { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 48px; }
.section-head .eyebrow { color: var(--brand); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.section-head h2 { font-size: clamp(28px, 3.5vw, 40px); letter-spacing: -.02em; margin: 10px 0; }
.section-head p { color: var(--muted); font-size: 17px; }

.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.feature {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; transition: .2s; box-shadow: var(--shadow);
}
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.feature .ico {
  width: 50px; height: 50px; border-radius: 13px; display: grid; place-items: center;
  background: rgba(79,70,229,.1); color: var(--brand); margin-bottom: 18px;
}
.feature h3 { font-size: 19px; margin-bottom: 8px; letter-spacing: -.01em; }
.feature p { color: var(--muted); font-size: 15px; }

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(3,1fr); gap: 28px; }
.step { text-align: center; position: relative; }
.step .num {
  width: 56px; height: 56px; border-radius: 50%; background: var(--brand-grad); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 800; margin: 0 auto 18px;
  box-shadow: 0 8px 18px rgba(79,70,229,.35);
}
.step h3 { font-size: 18px; margin-bottom: 6px; }
.step p { color: var(--muted); font-size: 15px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #cbd5e1; padding: 56px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; margin-bottom: 40px; }
.footer-grid h4 { color: #fff; font-size: 15px; margin-bottom: 14px; }
.footer-grid a { display: block; color: #94a3b8; font-size: 14px; padding: 5px 0; transition: .15s; }
.footer-grid a:hover { color: #fff; }
.footer-grid .brand { color: #fff; margin-bottom: 12px; }
.footer-grid p { color: #94a3b8; font-size: 14px; }
.footer-bottom { border-top: 1px solid #1e293b; padding-top: 22px; display: flex; justify-content: space-between; align-items: center; color: #64748b; font-size: 14px; }

/* ============================================================
   Stats page
   ============================================================ */
.page-head { background: #fff; border-bottom: 1px solid var(--line); padding: 32px 0; }
.page-head .crumb { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.page-head h1 { font-size: 28px; letter-spacing: -.02em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .target { color: var(--muted); font-size: 15px; margin-top: 6px; word-break: break-all; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.pill.live { background: rgba(22,163,74,.12); color: var(--ok); }
.pill.warn { background: rgba(217,119,6,.12); color: var(--warn); }

.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; margin: 28px 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stat .v { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; }
.stat .d { font-size: 13px; margin-top: 4px; }
.stat .d.up { color: var(--ok); }
.stat .d.down { color: var(--danger); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-head h3 { font-size: 18px; }
.tabs { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; font-family: var(--font); font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.tabs button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 12px; font-size: 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td { color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }
.bar-cell { display: flex; align-items: center; gap: 10px; }
.bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; max-width: 200px; }
.bar-fill { height: 100%; background: var(--brand-grad); border-radius: 999px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* ============================================================
   Redirect / Interstitial ad page
   ============================================================ */
.redirect-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.redirect-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.redirect-box {
  width: 100%; max-width: 760px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.redirect-top { padding: 28px 30px; text-align: center; border-bottom: 1px solid var(--line); }
.redirect-top h2 { font-size: 22px; letter-spacing: -.01em; }
.redirect-top p { color: var(--muted); margin-top: 6px; }
.countdown {
  width: 92px; height: 92px; border-radius: 50%; margin: 18px auto 0;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--brand) var(--p,0%), var(--line) 0);
}
.countdown::before { content:""; position: absolute; inset: 7px; background: #fff; border-radius: 50%; }
.countdown span { position: relative; font-size: 32px; font-weight: 800; color: var(--brand); }
.ad-slot {
  margin: 0; background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 12px, #e9eef5 12px, #e9eef5 24px);
  border: 2px dashed #cbd5e1; border-radius: 12px;
  display: grid; place-items: center; color: #94a3b8; font-weight: 700; font-size: 14px; text-align: center;
}
.ad-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; text-align: center; margin: 4px 0; }
.redirect-body { padding: 26px 30px; }
.redirect-target {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.redirect-target .fav { width: 38px; height: 38px; border-radius: 9px; background: var(--brand-grad); display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.redirect-target .meta { overflow: hidden; }
.redirect-target .meta .t { font-weight: 700; font-size: 15px; }
.redirect-target .meta .u { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.redirect-foot { text-align: center; padding: 0 30px 28px; }

/* ============================================================
   Admin
   ============================================================ */
.admin { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #cbd5e1; padding: 22px 16px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; font-size: 19px; margin-bottom: 26px; padding: 0 8px; }
.side-group { margin-bottom: 22px; }
.side-group .gl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 0 12px; margin-bottom: 8px; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #94a3b8; font-weight: 500; font-size: 15px; cursor: pointer; transition: .15s; }
.side-link:hover { background: #1e293b; color: #fff; }
.side-link.active { background: var(--brand); color: #fff; }
.side-link svg { flex-shrink: 0; }

.admin-main { background: var(--bg); }
.admin-top { background: #fff; border-bottom: 1px solid var(--line); padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.admin-top h1 { font-size: 20px; }
.admin-top .right { display: flex; align-items: center; gap: 14px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.search input { border: 0; background: transparent; outline: 0; font-family: var(--font); font-size: 14px; width: 200px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.admin-body { padding: 28px; }
.admin-page { display: none; }
.admin-page.active { display: block; animation: pop .3s ease; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 14px; flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.data-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.data-card table th { background: var(--bg); }
.mono { font-family: 'SF Mono', ui-monospace, monospace; font-size: 13px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.tag.on { background: rgba(22,163,74,.12); color: var(--ok); }
.tag.off { background: rgba(100,116,139,.12); color: var(--muted); }
.tag.ad { background: rgba(79,70,229,.1); color: var(--brand); }
.row-actions { display: flex; gap: 6px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--muted); transition: .15s; }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.ad-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.ad-preview { height: 130px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); margin-bottom: 14px; overflow: hidden; }
.ad-card h4 { font-size: 16px; display: flex; align-items: center; justify-content: space-between; }
.ad-card .meta { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }

/* toggle */
.toggle { position: relative; width: 42px; height: 24px; }
.toggle input { display: none; }
.toggle .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.toggle .track::before { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; box-shadow: var(--shadow); }
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track::before { left: 21px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--brand-grad); padding: 20px; }
.login-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg); padding: 38px; width: 100%; max-width: 400px; }
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card p.sub { text-align: center; color: var(--muted); margin-bottom: 26px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; color: var(--ink-2); }
.form-group input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 13px 14px; font-family: var(--font); font-size: 15px; outline: 0; }
.form-group input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .25s; z-index: 100; display: flex; align-items: center; gap: 8px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-3, .grid-4, .steps, .stat-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .admin { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
@media (max-width: 560px) {
  .grid-3, .grid-4, .steps, .stat-grid, .footer-grid { grid-template-columns: 1fr; }
  .create-row { flex-direction: column; }
  .hero { padding: 48px 0 36px; }
  .section { padding: 48px 0; }
}
