:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --text: #15202b;
  --muted: #5d6b7a;
  --line: #d9e2ec;
  --primary: #0b3d5c;
  --accent: #1a7a6d;
  --accent-soft: #e7f5f2;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #166534;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --radius: 14px;
  --sidebar: 250px;
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  background: var(--primary);
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.brand {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 14px;
}
.brand strong { font-size: 18px; letter-spacing: .2px; }
.brand span { font-size: 12px; opacity: .75; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.86);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  text-decoration: none;
  font-size: 14px;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.nav .nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  opacity: .55; padding: 12px 12px 6px; font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.user-chip {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted);
}
.user-chip b { color: var(--text); }
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.badge.danger { background: #fee2e2; color: var(--danger); }
.badge.warn { background: #ffedd5; color: var(--warn); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.muted { background: #eef2f6; color: var(--muted); }

.content { padding: 22px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-body { padding: 16px; }

.stat {
  padding: 16px;
}
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat .value { font-size: 24px; font-weight: 700; color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; text-decoration: none; background: var(--line); color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-dark { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.form-row { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,122,109,.12);
}
textarea { min-height: 90px; resize: vertical; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: #f8fafc; position: sticky; top: 0;
}
table.data tr:hover td { background: #fafcfe; }

.alert {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px;
  border: 1px solid var(--line); background: #fff;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }
.alert-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert-info { background: var(--accent-soft); border-color: #9ed8cf; color: var(--primary); }

.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(circle at 10% 10%, rgba(26,122,109,.15), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(11,61,92,.18), transparent 40%),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--primary); }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.scan-hero {
  background: linear-gradient(135deg, #0b3d5c, #145f5a);
  color: #fff; border-radius: var(--radius); padding: 18px;
  margin-bottom: 14px;
}
.scan-hero h2 { margin: 0 0 6px; font-size: 18px; }
.scan-hero p { margin: 0; opacity: .85; font-size: 13px; }

.btn-lg { padding: 14px 18px; font-size: 15px; border-radius: 12px; }
.scan-input {
  font-size: 18px !important; letter-spacing: 1px; font-weight: 700;
}
.scan-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
}
.scan-actions .btn { flex: 1; min-width: 180px; }
.camera-box {
  border-radius: 14px; overflow: hidden; background: #0b1220;
  min-height: 240px; border: 1px solid var(--line);
  width: 100%;
}
.camera-box video,
.login-camera-overlay__view video {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 220px;
  object-fit: cover;
  display: block !important;
  background: #000;
}
.login-camera-overlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  background: #0b1220;
  color: #fff;
  padding: 0 0 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  max-height: 85vh;
  overflow: auto;
}
.login-camera-overlay[hidden] { display: none !important; }
.login-camera-overlay__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px;
  background: #145f5a;
}
.login-camera-overlay__view {
  width: 100%;
  min-height: 280px;
  background: #000;
}
.login-camera-overlay__view img {
  display: none !important; /* tránh qrbox che video trên một số máy */
}
.login-camera-overlay__hint {
  margin: 0 12px; font-size: 13px; opacity: .9; line-height: 1.4;
}
.login-camera-panel {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 0 0 16px;
}
.scan-ways { display: grid; gap: 10px; }
.scan-way {
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.scan-way b { display: block; margin-bottom: 4px; font-size: 13px; }
.scan-way p { margin: 0; font-size: 13px; }
@media (max-width: 960px) {
  .scan-actions { flex-direction: column; }
  .scan-actions .btn { width: 100%; }
}
.result-flash {
  padding: 14px; border-radius: 12px; background: var(--accent-soft);
  border: 1px solid #9ed8cf; margin-top: 12px; display: none;
}
.result-flash.show { display: block; }
.result-flash.error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--muted); }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.w-100 { width: 100%; }

.qr-box {
  display: grid; place-items: center; padding: 20px;
  background: #fff; border: 1px dashed var(--line); border-radius: 14px;
}

@media (max-width: 960px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  }
  .brand { width: 100%; border: 0; margin: 0; padding-bottom: 8px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .nav .nav-label { display: none; }
  .nav a { margin: 0; padding: 8px 10px; font-size: 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
}
