:root {
  --ground: #f2f4f1;
  --surface: #ffffff;
  --sunk: #e9ede8;
  --ink: #131c1a;
  --ink-soft: #4a5854;
  --ink-faint: #7c8985;
  --rule: #d6dcd5;
  --accent: #0d6b58;
  --accent-soft: #d7eae3;
  --warn: #8a5b00;
  --neg: #9a3b2e;
  --radius: 6px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ground);
}

/* ---------------------------------------------------------- đăng nhập */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 32px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; }

input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--rule);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: var(--surface); color: var(--ink); border-color: var(--rule); }
button.link {
  background: none; border: none; color: var(--accent); padding: 0;
  text-align: left; font-weight: 500;
}
button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------- khung */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--rule);
  padding: 20px 16px; display: flex; flex-direction: column; gap: 20px;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a {
  padding: 7px 10px; border-radius: var(--radius); color: var(--ink-soft);
  text-decoration: none; font-weight: 500;
}
#nav a:hover { background: var(--sunk); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.me { border-top: 1px solid var(--rule); padding-top: 14px; font-size: 13px; }

main { padding: 26px 30px 60px; overflow-x: hidden; }
.loading { color: var(--ink-faint); }

h2 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.muted { color: var(--ink-faint); }
.err { color: var(--neg); font-weight: 500; }
.ok { color: var(--accent); font-weight: 600; }

/* ---------------------------------------------------------- bảng */
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-faint); padding: 10px 14px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--sunk); color: var(--ink-soft);
}
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: #f6e9ce; color: var(--warn); }
.pill.neg { background: #f6dcd7; color: var(--neg); }

/* ---------------------------------------------------------- thẻ & lưới */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 16px;
}
.card h3 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-faint); }
.card .big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }

/* ---------------------------------------------------------- lịch */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
}
.cal-dow { background: var(--sunk); padding: 7px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); text-align: center; }
.cal-cell { background: var(--surface); min-height: 96px; padding: 6px; font-size: 12px; }
.cal-cell.dim { background: var(--ground); color: var(--ink-faint); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-date { font-weight: 600; margin-bottom: 4px; }
.cal-ev {
  display: block; background: var(--accent-soft); color: var(--accent);
  border-radius: 3px; padding: 2px 5px; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-ev.leave { background: #f6e9ce; color: var(--warn); }

dialog {
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 22px; max-width: 520px; width: 92%;
}
dialog::backdrop { background: rgba(19, 28, 26, .4); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 18px; }
}

/* ---------------------------------------------------------- thông báo */
.notif { display: flex; flex-direction: column; gap: 4px; }
.notif:empty { display: none; }
.notif-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; font-size: 12px; margin-bottom: 2px;
}
.notif-item {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 7px 9px; font-size: 12px; text-decoration: none; color: var(--ink);
}
.notif-item:hover { filter: brightness(.97); }
.notif-item span { font-size: 11px; }

/* ---------------------------------------------------------- in phiếu lương */
@media print {
  .sidebar, .page-head, .no-print, #nav, .notif { display: none !important; }
  main { padding: 0; }
  .shell { display: block; }
  body { background: #fff; }
  #main > *:not(#slip-detail) { display: none !important; }
  .printable { border: none !important; box-shadow: none !important; max-width: 100% !important; }
}
