:root {
  --bg: #050a1c;
  --bg-2: #0b1736;
  --panel: #0e1d42;
  --panel-2: #132757;
  --line: #2a4a8f;
  --text: #eef3ff;
  --muted: #9fb2dc;
  --accent: #3c8cff;
  --accent-2: #78b5ff;
  --orange: #f6a31b;
  --orange-2: #ffbf47;
  --green: #4cc93a;
  --red: #e5413a;
  --gold: #ffd76a;
  --radius: 12px;
  --font: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(ellipse at 50% 0%, #17306b 0%, var(--bg) 60%) fixed, var(--bg);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }
.center { text-align: center; }
.spacer { height: 12px; }

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.card h2, .card h3 { color: var(--gold); }

button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid #4b7fe0;
  background: linear-gradient(180deg, #2c62c9, #1a3f8f);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  transition: filter .15s, transform .05s;
  user-select: none;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.15); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #ffb836, #e07d00); border-color: #ffc965; color: #1b1000; }
button.success { background: linear-gradient(180deg, #4fd13f, #24861a); border-color: #84e874; }
button.danger { background: linear-gradient(180deg, #ef5a52, #a8231d); border-color: #ff8c86; }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.sm { padding: 6px 10px; min-height: 32px; font-size: .9em; }
button.lg { padding: 14px 22px; min-height: 54px; font-size: 1.1em; }
button.block { width: 100%; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #071230;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 42px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--orange); transform: scale(1.2); }
label { display: block; font-size: .9em; color: var(--muted); margin-bottom: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text); margin: 0; }
.field { margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: .92em; }
th, td { padding: 8px 10px; border-bottom: 1px solid rgba(80, 120, 200, .25); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: rgba(20, 40, 90, .5); position: sticky; top: 0; }
tr.err td { background: rgba(229, 65, 58, .12); }
tr.warn td { background: rgba(246, 163, 27, .12); }
.table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 10px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78em;
  font-weight: 700;
  background: #23407f;
  color: #cfe0ff;
  white-space: nowrap;
}
.badge.on { background: #1f7a2a; color: #d9ffd2; }
.badge.off { background: #5a2323; color: #ffd6d4; }
.badge.warn { background: #7a5410; color: #ffe7b8; }
.badge.ai { background: #3d2a78; color: #e3d8ff; }

.toast-wrap { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 520px); }
.toast { background: #1d2f5e; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: toastIn .2s ease-out; width: 100%; }
.toast.error { background: #5a1a17; border-color: #c2413b; }
.toast.ok { background: #17451d; border-color: #3fae3a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(640px, 100%); max-height: 90vh; overflow: auto; }

.conn { position: fixed; top: 8px; right: 8px; z-index: 50; font-size: .75em; padding: 3px 8px; border-radius: 999px; background: #5a1a17; }
.conn.ok { display: none; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { background: transparent; border-color: var(--line); }
.tabs button.active { background: linear-gradient(180deg, #ffb836, #e07d00); color: #1b1000; border-color: #ffc965; }

.blur-answer { filter: blur(7px); transition: filter .15s; cursor: help; }
.blur-answer:hover { filter: none; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 6px 12px; border-radius: 999px; background: #18306a; border: 1px solid var(--line); font-weight: 600; }
.pill.off { opacity: .45; }
.pill.pending { border-color: var(--orange); }

/* Form đăng nhập tài khoản */
.login-wrap { max-width: 420px; margin: 9vh auto; padding: 0 16px; }
.login-card { padding: 26px 24px; border-radius: 18px; }
.login-card h2 { text-align: center; margin-bottom: 14px; }
.login-ic { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; display: grid; place-items: center; font-size: 1.9em; background: linear-gradient(160deg, #ffcf5a, #e07d00); box-shadow: 0 6px 20px rgba(246, 163, 27, .35); }
.login-card input { min-height: 48px; }
.login-msg { text-align: center; color: var(--orange-2); margin: -4px 0 14px; }
.login-hint { font-size: .85em; color: var(--muted); text-align: center; margin: 14px 0 0; }
.login-back { display: block; text-align: center; margin-top: 12px; font-size: .9em; text-decoration: none; }

@media (max-width: 640px) {
  .card { padding: 12px; }
  button { padding: 10px 12px; }
}
