/* Kho tài khoản — giao diện (ưu tiên điện thoại, tự đổi nền tối theo máy) */
:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --field: #f7f8fa;
  --field-hover: #eef1f4;
  --primary: #0f766e;
  --primary-hover: #0b5f59;
  --primary-ink: #ffffff;
  --primary-soft: #e6f4f2;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 10px rgba(16, 24, 40, .05);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d;
    --card: #161b26;
    --text: #f0f2f5;
    --muted: #98a2b3;
    --line: #262d3b;
    --field: #1e2532;
    --field-hover: #252d3c;
    --primary: #2bb5a8;
    --primary-hover: #3cc9bb;
    --primary-ink: #052e2b;
    --primary-soft: #12302e;
    --danger: #f97066;
    --danger-soft: #2d1614;
    --warn: #fdb022;
    --warn-soft: #2b2112;
    --ok: #47cd89;
    --ok-soft: #10261b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); }
h1 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 16px; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 8px; }
.mono { font-family: var(--mono); }
.ok-text { color: var(--ok); }
.bad-text { color: var(--danger); }
.grow { flex: 1; }
.boot-loading, .noscript { padding: 40px 16px; text-align: center; color: var(--muted); }

.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Khung trang ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-stats { display: flex; gap: 6px; font-size: 13px; color: var(--muted); }
.mini-stats span { background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.mini-stats b { color: var(--text); }
.wrap { max-width: 560px; margin: 0 auto; padding: 14px 12px 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 960px; }
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card.narrow { width: 100%; max-width: 400px; }
.card.login { text-align: center; }
.logo {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.logo .ico { width: 26px; height: 26px; }

/* ---------- Ô nhập, nút ---------- */
.input {
  display: block; width: 100%; margin: 0 0 12px; padding: 11px 12px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--field); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 160px; font-size: 13px; line-height: 1.5; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
select.input { appearance: auto; }
.lbl { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; text-align: left; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; user-select: none;
  background: var(--field); color: var(--text); transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--card); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--field-hover); }
.btn-ghost.danger { color: var(--danger); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 50px; font-size: 17px; }
.btn-xl { min-height: 60px; font-size: 19px; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn-mail { background: var(--primary-soft); color: var(--primary); min-height: 50px; }
.icon-btn {
  width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: var(--primary); cursor: pointer; text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn-row .btn { flex: 1 1 160px; }
.file-btn input { display: none; }
.inline-form { display: flex; gap: 8px; align-items: flex-start; }
.inline-form .input { margin-bottom: 0; }

.spin {
  display: inline-block; width: 16px; height: 16px; vertical-align: -3px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Trang nhân viên ---------- */
.empty { text-align: center; padding: 28px 16px; }
.empty-ico {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.empty-ico .ico { width: 30px; height: 30px; }
.empty p { color: var(--muted); }

.acc-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.acc-no { font-weight: 700; font-size: 13px; color: var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 2px 8px; margin-right: 6px; }

.field { padding: 8px 0; border-top: 1px solid var(--line); }
.acc-head + .field { border-top: 0; }
.field-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 5px; display: flex; justify-content: space-between; }
.field-line { display: flex; gap: 8px; align-items: stretch; }
.field-value {
  flex: 1; min-width: 0; text-align: left; padding: 10px 12px; min-height: 46px;
  font: 600 16px/1.35 var(--mono); color: var(--text); word-break: break-all;
  background: var(--field); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.field-value:hover { background: var(--field-hover); }
.copy-btn {
  flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 64px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--primary); color: var(--primary-ink); font: 600 12px/1 system-ui, sans-serif;
}
.copy-btn:active, .field-value:active { transform: scale(.98); }
.copied { outline: 3px solid var(--ok); outline-offset: 1px; }

.otp .otp-code { font-size: 28px; letter-spacing: .08em; color: var(--primary); text-align: center; }
.otp .otp-left { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--primary); }
.otp-bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.otp-bar i { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: 4px; transition: width .25s linear; }
.otp.low .otp-code, .otp.low .otp-left { color: var(--danger); }
.otp.low .otp-bar i { background: var(--danger); }
.otp.bad .otp-code { font-size: 15px; color: var(--danger); letter-spacing: 0; }
.otp-raw { margin-top: 4px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 10px; }
.actions .btn { min-height: 52px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- Khung lấy mã Hotmail ---------- */
.mail-status { margin-top: 8px; font-size: 14px; color: var(--muted); }
.mail-status:empty { display: none; }
.code-box { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--ok-soft); text-align: center; }
.code-box.old { background: var(--warn-soft); }
.code-meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.code-big {
  display: block; width: 100%; padding: 6px; margin-bottom: 8px; border: 0; background: none; cursor: pointer;
  font: 700 34px/1.2 var(--mono); letter-spacing: .12em; color: var(--ok);
}
.code-box.old .code-big { color: var(--warn); }
.mail-list { margin-top: 12px; }
.mail-item { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.mail-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-top b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-top .muted { flex: none; font-size: 12px; }
.mail-subj { margin: 2px 0 4px; }
.mail-prev { font-size: 13px; color: var(--muted); }
.chip-code { display: inline-block; margin: 2px 0 4px; padding: 3px 10px; border-radius: 999px; border: 0; cursor: pointer; font: 700 14px var(--mono); background: var(--primary-soft); color: var(--primary); }
.mail-empty { margin-top: 12px; color: var(--muted); text-align: center; }
.mail-error { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.mail-error details { margin-top: 6px; }
.mail-error summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.mail-error small { display: block; margin-top: 6px; color: var(--muted); word-break: break-word; }

/* ---------- Thông báo nhỏ ---------- */
#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px;
  background: #101828; color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { background: #067647; }
#toast.error { background: #b42318; }
#toast.warn { background: #b54708; }

/* ---------- Trang quản lý ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat b { font-size: 24px; }
.tabs, .seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.tabs button, .seg button {
  flex: 1; white-space: nowrap; min-height: 40px; padding: 6px 12px; border: 0; border-radius: 9px;
  font: inherit; font-weight: 600; font-size: 15px; color: var(--muted); background: transparent; cursor: pointer;
}
.tabs button.on, .seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg button { font-size: 14px; padding: 6px 8px; }
.preview { font-size: 14px; margin: -4px 0 12px; }
.preview:empty { display: none; }
.preview-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0; padding: 10px 12px; background: var(--field); border-radius: 10px; }
.preview-grid b { word-break: break-all; }
.result { margin-top: 12px; padding: 12px; border-radius: 10px; font-size: 14px; }
.result.ok { background: var(--ok-soft); }
.result.warn { background: var(--warn-soft); }
.result code { display: block; margin-top: 4px; font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--muted); }

.list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.rows { border-top: 1px solid var(--line); }
.item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.item-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.item-info { flex: 1 1 260px; min-width: 0; }
.item-title { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.item-title .mono { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 13px; }
.item-meta .mono { word-break: break-all; }
.badge { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--field); border: 1px solid var(--line); }
.badge.free { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.taken { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.item-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.item-detail { margin-top: 10px; }
.item-detail .card { margin-bottom: 8px; background: var(--bg); box-shadow: none; }
.net-out { margin-top: 10px; }
.net-row { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; margin-top: 6px; font-size: 14px; }
.net-row.ok { background: var(--ok-soft); }
.net-row.ok b { color: var(--ok); }
.net-row.bad { background: var(--danger-soft); }
.net-row.bad b { color: var(--danger); }
.net-row .muted { word-break: break-word; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.info-grid b { color: var(--text); word-break: break-all; font-weight: 600; }

@media (max-width: 420px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 16px; }
  .mini-stats { gap: 4px; font-size: 12px; }
  .mini-stats span { padding: 3px 7px; }
  .stat-grid { gap: 6px; }
  .stat { padding: 10px; }
  .stat b { font-size: 20px; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
