:root {
  --bg: #0f1c2e;
  --bg-soft: #162640;
  --card: #1b2f4a;
  --line: #2d4566;
  --text: #eef3f9;
  --muted: #9bb0c9;
  --accent: #2f9e7b;
  --accent-2: #3d7ec9;
  --danger: #d46565;
  --warn: #d4a017;
  --radius: 16px;
  --font: "Segoe UI", "Be Vietnam Pro", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1f4d7a55, transparent),
    radial-gradient(900px 500px at 100% 0%, #1f7a5a33, transparent),
    var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-brand {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 4px;
}

.login-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 6px 18px #00000045;
}

.login-title {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 3.6vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.card {
  background: color-mix(in srgb, var(--card) 92%, white 8%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 12px 40px #00000040;
}

.stack {
  display: grid;
  gap: 12px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
}

.field-label {
  font-size: 0.9rem;
  color: var(--muted);
}

#passwordWrap.password-field {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  padding-right: 6px;
  box-sizing: border-box;
}

#passwordWrap.password-field:focus-within {
  border-color: #9bb0c9;
}

#passwordWrap > input {
  flex: 1 1 auto !important;
  width: 0 !important; /* quan trọng để flex không đẩy nút xuống hàng */
  min-width: 0 !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}

#passwordWrap > button.password-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  min-height: 0 !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  background: #243552 !important;
  color: #eef3f9 !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  box-shadow: none !important;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, #3bb892 0%, var(--accent) 100%);
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    0 1px 0 #ffffff33 inset,
    0 6px 14px #00000055,
    0 2px 0 #1f6b52;
  transform: translateY(0);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 #ffffff44 inset,
    0 10px 18px #00000066,
    0 2px 0 #1f6b52;
}

button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 #ffffff22 inset,
    0 3px 8px #00000044,
    0 1px 0 #1f6b52;
}

button.secondary {
  background: linear-gradient(180deg, #5a97d8 0%, var(--accent-2) 100%);
  box-shadow:
    0 1px 0 #ffffff33 inset,
    0 6px 14px #00000055,
    0 2px 0 #2a5f9a;
}

/* Đã gửi xin xác nhận thành công */
button.btn-sent {
  background: linear-gradient(180deg, #e0a84a 0%, #c4841f 100%);
  box-shadow:
    0 1px 0 #ffffff33 inset,
    0 6px 14px #00000055,
    0 2px 0 #8a5a10;
  color: #fff8e8;
}

button.btn-sent:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow:
    0 1px 0 #ffffff44 inset,
    0 10px 18px #00000066,
    0 2px 0 #8a5a10;
}

button.secondary:hover:not(:disabled) {
  box-shadow:
    0 1px 0 #ffffff44 inset,
    0 10px 18px #00000066,
    0 2px 0 #2a5f9a;
}

button.secondary:active:not(:disabled) {
  box-shadow:
    0 1px 0 #ffffff22 inset,
    0 3px 8px #00000044,
    0 1px 0 #2a5f9a;
}

button.ghost {
  background: linear-gradient(180deg, #2b3f5c 0%, #22344d 100%);
  border: 1px solid #3d5678;
  color: var(--text);
  box-shadow:
    0 1px 0 #ffffff22 inset,
    0 5px 12px #00000050,
    0 2px 0 #152338;
}

button.ghost:hover:not(:disabled) {
  background: linear-gradient(180deg, #355074 0%, #2a405c 100%);
  border-color: #54729a;
  box-shadow:
    0 1px 0 #ffffff33 inset,
    0 8px 16px #00000060,
    0 2px 0 #152338;
}

button.ghost:active:not(:disabled) {
  box-shadow:
    0 1px 0 #ffffff18 inset,
    0 2px 6px #00000040,
    0 1px 0 #152338;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: none;
}

/* Nút Sửa / thao tác trong bảng — cao ~1/3 nút thường */
button.btn-sm,
button.ghost.btn-sm {
  padding: 3px 8px;
  min-height: 0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 8px;
  box-shadow:
    0 1px 0 #ffffff18 inset,
    0 2px 6px #00000040,
    0 1px 0 #152338;
}

button.btn-sm:hover:not(:disabled),
button.ghost.btn-sm:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 #ffffff22 inset,
    0 3px 8px #00000050,
    0 1px 0 #152338;
}

button.btn-sm:active:not(:disabled),
button.ghost.btn-sm:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    0 1px 0 #ffffff10 inset,
    0 1px 3px #00000035,
    0 1px 0 #152338;
}

.muted {
  color: var(--muted);
}

.error {
  color: #ffb4b4;
  background: #5a1f1f55;
  border: 1px solid #8a3535;
  padding: 10px 12px;
  border-radius: 12px;
}

.text-danger {
  color: #ff6b6b;
  font-weight: 600;
}

.miss-fieldset {
  margin: 0;
  padding: 14px 14px 16px;
  border: 2px solid #c62828;
  border-radius: 12px;
  min-inline-size: 0;
}

.miss-legend {
  margin: 0;
  padding: 0 8px;
  float: none;
  width: auto;
  font-size: 1rem;
  line-height: 1.3;
  background: color-mix(in srgb, var(--card) 92%, white 8%);
}

.ok {
  color: #b8f0d8;
  background: #1f5a4555;
  border: 1px solid #2f9e7b;
  padding: 10px 12px;
  border-radius: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}

.badge.on {
  border-color: #2f9e7b;
  color: #b8f0d8;
}

.badge.off {
  border-color: #8a3535;
  color: #ffb4b4;
}

.hero-check {
  text-align: center;
  padding: 28px 18px;
}

.hero-check h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.big-btn {
  width: 100%;
  min-height: 64px;
  font-size: 1.15rem;
  border-radius: 18px;
}

.layout-admin {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0c1626;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.sidebar a {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
}

.sidebar a.active,
.sidebar a:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.emp-tabs {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

button.ghost.emp-tab.active {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--accent-2);
  font-weight: 700;
}

.main {
  padding: 20px;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: #0f1c2e55;
}

.busy-overlay[hidden] {
  display: none !important;
}

.busy-toast {
  pointer-events: none;
  padding: 14px 22px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 92%, white 8%);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 12px 40px #00000055;
}

table {
  width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--line);
  font-size: 0.92rem;
}

th,
td {
  border: 2px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: color-mix(in srgb, var(--bg-soft) 80%, transparent);
}

@media (max-width: 860px) {
  .layout-admin {
    grid-template-columns: 1fr;
  }
  .sidebar {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
