:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0068ff; /* Zalo blue */
  --primary-dark: #0052cc;
  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  background: #0f172a;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.nav-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-tab {
  background: transparent;
  color: #cbd5e1;
  border: none;
  padding: 7px 13px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.nav-tab:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-tab.active { background: var(--primary); color: #fff; }

.user-box { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.container { max-width: 1260px; margin: 0 auto; padding: 18px 16px 48px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-card {
  background: #fff;
  width: 100%;
  max-width: 430px;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.quick-accounts {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
}
.quick-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.chip-btn:hover { background: #e2e8f0; }

.card {
  background: var(--surface);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; font-weight: 600; color: #334155; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(0, 104, 255, 0.2);
  border-color: var(--primary);
}
input[readonly] { background: #f8fafc; color: #475569; }

.btn {
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-warning { background: #d97706; color: #fff; border-color: #d97706; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.search-wrap { position: relative; }
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  max-height: 260px;
  overflow-y: auto;
  z-index: 30;
  display: none;
}
.search-dropdown.open { display: block; }
.search-item {
  padding: 8px 11px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}
.search-item:hover { background: #eff6ff; }
.search-item strong { color: var(--primary-dark); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: middle; }
th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 12px; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #e2e8f0; color: #334155; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 12px;
  z-index: 50;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 820px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal-head {
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}
.modal-body { padding: 18px; max-height: 82vh; overflow-y: auto; }
.close-btn { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); }

/* MISA Slip Preview (Hình 1 exact style) */
.slip-preview {
  background: #fff;
  border: 1px solid #94a3b8;
  padding: 22px 26px;
  font-family: 'Times New Roman', Times, serif;
  color: #000;
  line-height: 1.38;
}
.slip-company { font-size: 13px; font-weight: 700; text-transform: uppercase; }
.slip-addr { font-size: 12px; margin-bottom: 10px; max-width: 72%; }
.slip-title { text-align: center; font-size: 20px; font-weight: 700; margin: 8px 0 2px; }
.slip-date { text-align: center; font-style: italic; font-weight: 700; font-size: 13px; }
.slip-no { text-align: center; font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.slip-meta { font-size: 13px; margin-bottom: 12px; }
.slip-meta div { margin-bottom: 3px; }
.slip-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.slip-table th, .slip-table td {
  border: 1px solid #000;
  padding: 5px 7px;
  background: #fff;
  color: #000;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.slip-table th { text-align: center; font-weight: 700; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  display: none;
}
.toast.show { display: block; }

@media print {
  .topbar, .no-print, .modal-head { display: none !important; }
  .modal-backdrop { position: static; background: none; padding: 0; }
  .modal { box-shadow: none; max-width: 100%; }
  .slip-preview { border: none; padding: 0; }
}
