:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: #e9eef7;
  background: #0c111b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(80, 110, 255, .16), transparent 34%),
    #0c111b;
}

button, input { font: inherit; }

.topbar {
  max-width: 1500px;
  margin: 0 auto;
  padding: 42px 28px 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: .16em;
  color: #8290a8;
  font-weight: 800;
}

h1 {
  margin: 7px 0 6px;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -.04em;
}

h2 {
  margin: 0;
  font-size: 18px;
}

p, .muted {
  color: #8c9ab1;
  margin: 0;
}

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

.button, .copy-button, .icon-button {
  border: 1px solid #29334a;
  color: #e9eef7;
  background: #151c2a;
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: .15s ease;
}

.button:hover, .copy-button:hover, .icon-button:hover {
  transform: translateY(-1px);
  background: #1c2536;
}

.button.primary {
  background: #e8ecf7;
  color: #111827;
  border-color: transparent;
  font-weight: 800;
}

.button.danger { color: #ffb4b4; }
.button.small { padding: 8px 11px; font-size: 13px; }

.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 28px 40px;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 18px;
}

.panel {
  background: rgba(17, 24, 38, .85);
  border: 1px solid #202a3c;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0,0,0,.22);
}

.panel-header {
  padding: 18px 20px;
  min-height: 72px;
  border-bottom: 1px solid #202a3c;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.account-list { padding: 8px; }

.account-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 11px;
  align-items: center;
  padding: 11px;
  border-radius: 12px;
}

.account-row:hover { background: rgba(255,255,255,.035); }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: #202a3d;
  font-weight: 900;
}

.account-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.account-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.account-info span {
  color: #728099;
  font-size: 11px;
  line-height: 1.55;
}

.icon-button {
  border: 0;
  background: transparent;
  font-size: 21px;
  color: #77849c;
  padding: 5px 8px;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid #1e2738;
  text-align: left;
  font-size: 13px;
}

th {
  color: #748299;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

td { color: #cbd4e3; }

.otp {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: .08em;
  color: #fff;
}

.copy-button {
  padding: 7px 10px;
  font-size: 12px;
}

.subject {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap { white-space: nowrap; }

.live {
  color: #93a0b4;
  font-size: 12px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 999px;
  box-shadow: 0 0 0 5px rgba(74,222,128,.08);
}

.newest-row {
  animation: flash 1.8s ease;
}

@keyframes flash {
  0% { background: rgba(80, 120, 255, .18); }
  100% { background: transparent; }
}

.empty, .empty-box {
  text-align: center;
  color: #6f7d94;
  padding: 34px 18px;
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #edf1f8;
  color: #111827;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 750;
  transition: .2s ease;
  box-shadow: 0 14px 40px rgba(0,0,0,.3);
}

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

.email-mask { display: none; }

.login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  background: #111826;
  border: 1px solid #222d40;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #edf1f8;
  color: #111827;
  font-weight: 1000;
  margin-bottom: 20px;
}

.login-card h1 {
  font-size: 28px;
  margin: 0 0 8px;
}

.login-card p { margin-bottom: 22px; }

.login-card input {
  width: 100%;
  border: 1px solid #2a354a;
  outline: none;
  border-radius: 11px;
  background: #0c121d;
  color: white;
  padding: 12px 13px;
  margin-bottom: 10px;
}

.login-card button {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 12px;
  background: #edf1f8;
  color: #111827;
  font-weight: 850;
  cursor: pointer;
}

/* ---------- Admin: link + nhật ký ---------- */

.layout.secondary {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.link-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid #202a3c;
}

.link-form select,
.link-form input,
.mini-select {
  border: 1px solid #2a354a;
  background: #0c121d;
  color: #e9eef7;
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
  min-width: 0;
}

.mini-select { padding: 7px 9px; font-size: 13px; }

.link-list, .log-list {
  padding: 8px;
  max-height: 420px;
  overflow-y: auto;
}

.link-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
}

.link-row:hover { background: rgba(255,255,255,.035); }
.link-row.revoked { opacity: .45; }

.link-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.link-top {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 13px;
}

.tag {
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  background: #22304a;
  color: #a8bde0;
}

.tag.danger { background: #3a2028; color: #ffb4b4; }

.auto-tag {
  background: #14351f;
  color: #6ee7a0;
  font-size: 9.5px;
  white-space: nowrap;
}

.link-tag {
  background: #1f3326;
  color: #8ee0a8;
  font-size: 9.5px;
  white-space: nowrap;
}

.latest-code.is-link {
  font-size: 56px;
  color: #6ee7a0;
  letter-spacing: 0;
}

a.copy-button {
  display: inline-block;
  text-decoration: none;
  color: #8ee0a8;
  border-color: #2c4436;
  white-space: nowrap;
}

.link-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #8fb4ff;
  background: #0c121d;
  border: 1px solid #1e2738;
  border-radius: 8px;
  padding: 6px 8px;
  overflow-wrap: anywhere;
}

.link-meta { font-size: 11px; color: #6f7d94; }

.log-row {
  display: grid;
  grid-template-columns: auto 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border-radius: 10px;
}

.log-row:hover { background: rgba(255,255,255,.035); }

.log-time {
  font-size: 11px;
  color: #6f7d94;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #4b5568;
  flex-shrink: 0;
}

.dot.ok { background: #4ade80; }
.dot.danger { background: #f87171; }
.dot.info { background: #60a5fa; }
.dot.muted { background: #4b5568; }

.log-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-body strong { font-size: 12.5px; }

.log-body span {
  font-size: 11px;
  color: #7f8da4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-ip {
  font-size: 10.5px;
  color: #5f6c81;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Trang người dùng cuối ---------- */

.viewer-page {
  display: grid;
  place-items: start center;
  padding: 22px 16px 60px;
}

.viewer-shell { width: min(560px, 100%); }

.viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.viewer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  margin: 0;
  font-size: 17px;
  flex-shrink: 0;
}

.viewer-head h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: -.02em;
}

.viewer-email {
  font-size: 12.5px;
  color: #8c9ab1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-dot.off {
  background: #f87171;
  box-shadow: 0 0 0 5px rgba(248,113,113,.08);
}

.latest-card {
  background: rgba(17, 24, 38, .9);
  border: 1px solid #202a3c;
  border-radius: 20px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
}

.latest-card.flash { animation: cardFlash 1.6s ease; }

@keyframes cardFlash {
  0% { border-color: #6ea8ff; box-shadow: 0 0 0 6px rgba(110,168,255,.14); }
  100% { border-color: #202a3c; box-shadow: 0 18px 60px rgba(0,0,0,.25); }
}

.latest-label {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #8290a8;
  font-weight: 800;
}

.latest-code {
  font-size: clamp(40px, 13vw, 62px);
  font-weight: 900;
  letter-spacing: .12em;
  margin: 12px 0 6px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.latest-meta {
  font-size: 12.5px;
  color: #8c9ab1;
  margin-bottom: 18px;
}

.button.big {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  border-radius: 13px;
}

.button:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}

.viewer-history { margin-top: 26px; }

.viewer-history h2 {
  font-size: 13px;
  color: #8290a8;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 10px;
}

.history-list {
  background: rgba(17, 24, 38, .7);
  border: 1px solid #202a3c;
  border-radius: 16px;
  overflow: hidden;
}

.history-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #1e2738;
}

.history-row:last-child { border-bottom: 0; }

.history-code {
  font-weight: 900;
  font-size: 17px;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}

.history-src {
  font-size: 12px;
  color: #8c9ab1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  font-size: 11px;
  color: #6f7d94;
  white-space: nowrap;
}

.viewer-note {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: #6f7d94;
}

.invalid-box {
  width: min(440px, 100%);
  margin: 60px auto;
  text-align: center;
  background: #111826;
  border: 1px solid #222d40;
  border-radius: 20px;
  padding: 36px 28px;
}

/* ---------- Trang chính sách / điều khoản ---------- */

.doc-page { padding: 20px 16px 70px; }

.doc {
  max-width: 760px;
  margin: 0 auto;
  background: rgba(17, 24, 38, .85);
  border: 1px solid #202a3c;
  border-radius: 18px;
  padding: 38px 34px;
  line-height: 1.75;
}

.doc h1 { font-size: 28px; margin: 0 0 6px; }

.doc h2 {
  font-size: 16px;
  margin: 28px 0 8px;
  color: #e9eef7;
}

.doc p, .doc li { color: #a9b6ca; font-size: 14px; }
.doc ul { padding-left: 20px; margin: 8px 0; }
.doc li { margin-bottom: 5px; }
.doc a { color: #8fb4ff; }

.doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: #0c121d;
  border: 1px solid #1e2738;
  border-radius: 6px;
  padding: 2px 6px;
  overflow-wrap: anywhere;
}

.doc-updated { font-size: 12px; color: #6f7d94; margin-bottom: 6px; }

.doc-back {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid #202a3c;
}

@media (max-width: 600px) {
  .doc { padding: 26px 20px; }
}

.invalid-box h1 { font-size: 22px; margin-bottom: 10px; }
.invalid-box p { line-height: 1.7; font-size: 13.5px; }

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

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .accounts-panel { order: 2; }
  .codes-panel { order: 1; }

  .email-full { display: none; }
  .email-mask { display: inline; }

  .link-form { grid-template-columns: 1fr; }

  .log-row {
    grid-template-columns: auto 8px minmax(0, 1fr);
  }

  .log-ip { display: none; }
}
