/* ===== Tokens ===== */
:root {
  --navy-950: #0f1b2d;
  --navy-900: #14243a;
  --navy-800: #1c334f;
  --steel-600: #3d5a75;
  --steel-400: #6b8caa;
  --bg: #f4f6f8;
  --paper: #ffffff;
  --line: #dbe1e7;
  --text: #1b2733;
  --text-muted: #5c6b78;
  --amber: #b8791f;
  --amber-bg: #fbf1de;
  --red: #a3372c;
  --red-bg: #fbeae8;
  --green: #2c6e4f;
  --green-bg: #e9f4ee;
  --radius: 3px;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Inter", "Segoe UI", -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--steel-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Topbar ===== */
.topbar {
  background: var(--navy-950);
  border-bottom: 3px solid var(--steel-600);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: #fff;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 16px;
  color: #fff;
  border: 1px solid var(--steel-400);
  padding: 2px 6px;
  border-radius: var(--radius);
}
.brand-sub { font-size: 13px; color: #b7c4d1; display: none; }
@media (min-width: 700px) { .brand-sub { display: inline; } }

.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; row-gap: 6px; }
.nav a {
  color: #c9d4de;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
}
.nav a:hover { background: var(--navy-800); text-decoration: none; color: #fff; }
.nav a.active { background: var(--steel-600); color: #fff; }

.quick-search { display: flex; }
.quick-search input {
  background: var(--navy-800);
  border: 1px solid var(--navy-800);
  color: #fff;
  padding: 7px 10px;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 13px;
  width: 200px;
}
.quick-search input::placeholder { color: #8397a8; }
.quick-search button {
  background: var(--steel-600);
  color: #fff;
  border: none;
  padding: 0 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  font-size: 13px;
}

/* ===== Layout ===== */
.content { max-width: 1440px; margin: 0 auto; padding: 24px 20px 60px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-head h1 { font-size: 20px; margin: 0; font-weight: 700; color: var(--navy-950); }
.page-head .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--steel-600);
  display: block;
  margin-bottom: 4px;
}

/* ===== Cards / Panels ===== */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--navy-900);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-body { padding: 16px; }

/* ===== Dashboard stat grid ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--steel-600);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .num { font-family: var(--mono); font-size: 28px; font-weight: 700; color: var(--navy-950); }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.stat-card.warn { border-left-color: var(--amber); }
.stat-card.danger { border-left-color: var(--red); }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--line);
  padding: 8px 10px;
  white-space: nowrap;
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f8fafb; }
.table-wrap { overflow-x: auto; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-blue { background: #e6edf3; color: var(--steel-600); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: #eceef0; color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: #f0f2f4; text-decoration: none; }
.btn-primary { background: var(--navy-950); color: #fff; border-color: var(--navy-950); }
.btn-primary:hover { background: var(--navy-800); }
.btn-danger { color: var(--red); border-color: var(--red); background: var(--red-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--navy-900); }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
input[type=text], input[type=date], input[type=tel], input[type=search], select, textarea {
  font-family: var(--sans);
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid #c7d0d8;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--steel-400);
  outline-offset: 1px;
  border-color: var(--steel-600);
}
.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 160px;
  overflow-y: auto;
}
.checkbox-list label { font-weight: 400; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filter-bar .field { min-width: 160px; }
.btn-filter { min-width: 92px; text-align: center; }

/* ===== Detail sections ===== */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 20px; }
.kv-grid .kv label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 2px; }
.kv-grid .kv .val { font-size: 14px; color: var(--text); }

.empty-state { text-align: center; padding: 30px 10px; color: var(--text-muted); font-size: 13.5px; }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--steel-600);
  font-weight: 700;
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--navy-950);
  display: inline-block;
}

/* ===== Toi danh multi-select ===== */
.td-select {
  position: relative;
  border: 1px solid #c7d0d8;
  border-radius: var(--radius);
  background: #fff;
  padding: 6px 8px;
}
.td-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.td-chips:empty { margin-bottom: 0; }
.td-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e6edf3;
  color: var(--steel-600);
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 6px 3px 10px;
  border-radius: 999px;
}
.td-chip button {
  background: none;
  border: none;
  color: var(--steel-600);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.td-chip button:hover { color: var(--red); }
.td-input {
  border: none !important;
  padding: 4px 2px !important;
  width: 100%;
  outline: none;
}
.td-dropdown {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: 100%;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(15,27,45,0.12);
  max-height: 220px;
  overflow-y: auto;
}
.td-option { padding: 8px 12px; font-size: 13.5px; cursor: pointer; }
.td-option:hover { background: #f0f2f4; }
.td-option-new { color: var(--steel-600); font-weight: 600; border-top: 1px solid var(--line); }

/* Widget chon can bo - dung chung phan lon voi .td-select, chi them phan rieng */
.cb-select { position: relative; border: 1px solid #c7d0d8; border-radius: var(--radius); background: #fff; padding: 6px 8px; }
.cb-input-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-chip { display: inline-flex; align-items: center; gap: 6px; background: #e6edf3; color: var(--steel-600); font-size: 12.5px; font-weight: 600; padding: 3px 6px 3px 10px; border-radius: 999px; }
.cb-chip-cu { background: #f3f0e8; color: #8a7a4f; }
.cb-chip-note { font-weight: 400; font-size: 11px; }
.cb-chip button { background: none; border: none; color: var(--steel-600); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.cb-chip button:hover { color: var(--red); }
.cb-input { border: none !important; padding: 4px 2px !important; flex: 1; min-width: 160px; outline: none; }
.cb-arrow { color: var(--steel-400, #94a3b8); cursor: pointer; padding: 0 4px; user-select: none; }
.cb-dropdown { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(15,27,45,0.12); max-height: 220px; overflow-y: auto; }
.cb-option { padding: 8px 12px; font-size: 13.5px; cursor: pointer; }
.cb-option:hover { background: #f0f2f4; }
.cb-option-rong { color: var(--steel-400, #94a3b8); font-style: italic; cursor: default; }
.cb-option-rong:hover { background: none; }

/* Lam noi bat truong quan trong (VD: Can bo phu trach) ngay dau form */
.field-highlight {
  border: 2px solid var(--amber);
  background: var(--amber-bg);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.field-highlight > label { color: var(--amber); font-weight: 700; }
.field-highlight .cb-select { background: #fff; }
