:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --text: #17202e;
  --muted: #5d6879;
  --line: #dde3ec;
  --primary: #1f6feb;
  --primary-ink: #ffffff;
  --primary-soft: #e6efff;
  --danger: #c8312b;
  --danger-soft: #fdecea;
  --warn: #a65f00;
  --warn-soft: #fff3dc;
  --ok: #18794e;
  --ok-soft: #e3f5ec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e28;
    --surface-2: #1e2733;
    --text: #e7ecf3;
    --muted: #9aa7b8;
    --line: #2b3646;
    --primary: #5b9bff;
    --primary-ink: #0b1220;
    --primary-soft: #1c2c47;
    --danger: #ff7b72;
    --danger-soft: #3a1d1d;
    --warn: #f0b75a;
    --warn-soft: #3a2c14;
    --ok: #4fd18b;
    --ok-soft: #14301f;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

button, .btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  min-height: 38px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 600; }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .88rem; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  min-height: 38px;
  width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--primary-soft); color: var(--primary); }

.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: .92rem; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

/* Ô ngày kiểu ngày/tháng/năm (shared/datefield.js) */
.datef { position: relative; display: flex; gap: 6px; width: 100%; }
.datef input[data-datef] { flex: 1 1 auto; min-width: 0; font-variant-numeric: tabular-nums; }
.datef input.datef-bad { border-color: var(--danger); outline-color: var(--danger); }
.datef-btn { flex: 0 0 auto; padding: 0 10px; }
.datef-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-box .logo { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 12px; }
