* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: #111827; background: #f3f4f6; }
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

.alert-bar { background: #dc2626; color: #fff; padding: 10px 24px; font-weight: 500; }

.nav { background: #fff; border-bottom: 1px solid #e5e7eb; }
.nav-inner { display: flex; align-items: stretch; height: 60px; }
.nav-links { display: flex; gap: 4px; }
.nav-btn { display: none; }
.nav a { display: flex; align-items: center; color: #6b7280; padding: 0 12px; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: #374151; text-decoration: none; border-bottom-color: #d1d5db; }
.nav a.active { color: #111827; border-bottom-color: #6366f1; }
.nav .logo { display: flex; align-items: center; color: #16a34a; font-weight: 700; font-size: 18px; margin-right: 16px; padding-left: 0; border: 0; }

.page-head { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 28px; }
.page-head-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 80px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.page-head h1 { font-size: 20px; font-weight: 600; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }

.btn { display: inline-block; border: 1px solid transparent; border-radius: 6px; padding: 8px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; background: #1f2937; color: #fff; font-family: inherit; }
.btn:hover { background: #374151; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-light { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-light:hover { background: #f9fafb; }
.btn-green { background: #16a34a; }
.btn-green:hover { background: #15803d; }

.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 24px; }
.card-pad { padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.card-head h2 { font-size: 16px; margin: 0; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 18px; }
.stat .label { color: #4b5563; font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin: 4px 0; }
.stat .sub { color: #6b7280; font-size: 12px; }
.text-green { color: #16a34a; } .text-red { color: #dc2626; } .muted { color: #6b7280; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .grow { flex: 1 1 260px; }
input[type=text], input[type=date], input[type=number], select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 10px; font-size: 14px; font-family: inherit; background: #fff; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a5b4fc; border-color: #6366f1; }
.filters label { color: #4b5563; font-size: 13px; }
.spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; background: #f9fafb; padding: 12px; border-bottom: 1px solid #e5e7eb; }
td { padding: 12px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
tr:hover td { background: #fafafa; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.right, th.right { text-align: right; }
.trunc { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.wrap-text { display: block; max-width: 340px; min-width: 200px; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
.phone { font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a, .row-actions button { margin-left: 10px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: #4f46e5; }
.link-red { color: #dc2626; } .link-green { color: #16a34a; }
.inline { display: inline; margin: 0; }
.empty { padding: 32px; text-align: center; color: #6b7280; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #374151; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: #6b7280; }
.pager .pages a { display: inline-block; min-width: 32px; padding: 5px 8px; margin-left: 4px; text-align: center; border: 1px solid #e5e7eb; border-radius: 6px; color: #374151; }
.pager .pages a.active { background: #1f2937; color: #fff; border-color: #1f2937; }

.form { max-width: 720px; padding: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 500; margin-bottom: 6px; }
.field input[type=text], .field select, .field textarea { width: 100%; }
.field .hint { color: #6b7280; font-size: 12px; margin-top: 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.checks label { font-weight: normal; }

.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 20px; }
.flash-ok { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

dl.info { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; padding: 20px; }
dl.info dt { color: #6b7280; }
dl.info dd { margin: 0; }

code { word-break: break-all; }

@media (max-width: 1100px) {
  .nav-inner { height: auto; min-height: 56px; flex-wrap: wrap; }
  .nav-btn { display: flex; align-items: center; margin-left: auto; font-size: 24px; padding: 0 4px; cursor: pointer; user-select: none; }
  .nav-links { display: none; flex-basis: 100%; flex-direction: column; gap: 0; padding-bottom: 8px; }
  #nav-toggle:checked ~ .nav-links { display: flex; }
  .nav-links a { padding: 12px; border-bottom: 0; border-left: 3px solid transparent; }
  .nav-links a:hover { border-bottom: 0; }
  .nav-links a.active { border-left-color: #6366f1; background: #f5f5ff; }
}

@media (max-width: 768px) {
  .wrap { padding: 0 16px; }
  .page-head { margin-bottom: 16px; }
  .page-head-inner { min-height: 0; padding-top: 16px; padding-bottom: 16px; }
  .page-head h1 { font-size: 18px; }
  .actions .btn { padding: 8px 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 22px; }
  dl.info { grid-template-columns: 1fr; gap: 4px; }
  dl.info dd { margin-bottom: 10px; }

  /* Bộ lọc: mỗi ô một dòng */
  .filters { gap: 8px; }
  .filters > input, .filters > select, .filters .grow { flex: 1 1 100%; width: 100%; }
  .filters > label { flex: 0 0 100%; margin-bottom: -4px; }
  .filters > input[type=date] { flex: 1 1 40%; width: auto; }
  .filters .spacer { display: none; }
  .filters form.filters { flex: 1 1 100%; }

  /* Bảng -> thẻ */
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr.head { display: none; }
  .table-wrap tr { padding: 10px 16px; border-bottom: 1px solid #e5e7eb; }
  .table-wrap tr:hover td { background: none; }
  .table-wrap td { position: relative; padding: 4px 0; border: 0; white-space: normal; min-height: 26px; }
  .table-wrap td[data-label] { padding-left: 108px; }
  .table-wrap td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 6px; width: 96px; color: #6b7280; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  .table-wrap td.row-actions { display: block; text-align: right; padding-top: 8px; }
  .table-wrap td.row-actions::before { display: none; }
  .trunc, .wrap-text { max-width: 100% !important; min-width: 0; }
  .pager { flex-wrap: wrap; gap: 8px; }
}
