:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #667085;
  --border: #d9dee7;
  --border-soft: #edf0f5;
  --blue: #1f6feb;
  --blue-dark: #1756bb;
  --green: #0f8a4b;
  --green-bg: #e7f6ee;
  --red: #c93636;
  --red-bg: #fdeaea;
  --amber: #a16207;
  --amber-bg: #fff5d6;
  --gray-bg: #eef1f5;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--blue-dark);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0;
  font-size: 12px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.topbar-actions,
.header-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions form {
  margin: 0;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.health-text {
  color: var(--muted);
  font-size: 13px;
}

.shell {
  width: min(1360px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.section-header,
.table-tools {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.section-header p,
.table-tools p {
  color: var(--muted);
  margin-top: 4px;
}

.add-form {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(280px, 1fr) minmax(180px, 240px) auto auto;
  gap: 12px;
  align-items: end;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

input[type="text"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="password"] {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

input:focus {
  outline: 2px solid rgba(31, 111, 235, 0.18);
  border-color: var(--blue);
}

.check-label {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-label span {
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  text-decoration: none;
}

/* Specificity .button:hover (0,1,1) bằng a:hover (0,1,1) → cần đặt SAU và
   khai báo cả color/background/border để không bị a:hover ăn mất color. */
.button-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.button-primary:hover {
  background: var(--blue-dark);
  color: #fff;
  border-color: var(--blue-dark);
}

.button-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.button-secondary:hover {
  background: #f5faff;
  color: var(--blue);
  border-color: var(--blue);
}

.button-danger {
  background: #fff;
  color: var(--red);
  border-color: #f1c7c7;
}

.button-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* Button (cả <a> lẫn <button>) phải hoàn toàn miễn nhiễm với a:hover của site */
a.button:hover,
button.button:hover {
  text-decoration: none;
}

.button-small {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 12px;
}

/* Vòng xoay loading — dùng trong nút "Đang chạy" và card Trạng thái */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: rc-spin 0.6s linear infinite;
}

@keyframes rc-spin {
  to {
    transform: rotate(360deg);
  }
}

.search-input {
  max-width: 260px;
}

.summary-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  color: var(--muted);
}

.summary-strip > span {
  font-weight: 700;
  color: var(--text);
}

.summary-strip strong {
  min-width: 46px;
  display: grid;
  gap: 2px;
  text-align: center;
  font-size: 18px;
}

.summary-strip small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px 11px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fafbfc;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

tbody tr:hover {
  background: #fafcff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.actions {
  flex-wrap: nowrap;
}

td.actions {
  white-space: nowrap;
}

.actions form {
  margin: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}

.chip-green {
  background: var(--green-bg);
  color: var(--green);
}

.chip-red {
  background: var(--red-bg);
  color: var(--red);
}

.chip-amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.chip-gray {
  background: var(--gray-bg);
  color: #475467;
}

.count {
  font-weight: 750;
}

.count-green,
.text-green {
  color: var(--green);
}

.count-red,
.text-red {
  color: var(--red);
}

.count-amber,
.text-amber {
  color: var(--amber);
}

.count-blue,
.text-blue,
.text-info {
  color: var(--blue);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.alert {
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert-success {
  background: var(--green-bg);
  color: var(--green);
  border-color: #b7e5cc;
}

.alert-error {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f0b9b9;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

/* Canh giữa cho cột số */
td.num,
th.num,
.text-center {
  text-align: center;
}

/* Checkbox column */
td.check-col,
th.check-col {
  width: 36px;
  text-align: center;
  padding-left: 6px;
  padding-right: 6px;
}

/* Toolbar bulk actions */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: #fafbfc;
}

.bulk-toolbar .grow {
  flex: 1;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 14px 4px 4px;
  flex-wrap: wrap;
}

.pagination .page-info {
  color: var(--muted);
  font-size: 13px;
  margin: 0 8px;
}

.pagination a,
.pagination span.page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.pagination span.page-current {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.pagination a:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.pagination a.disabled,
.pagination span.page-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.run-list {
  display: grid;
  gap: 8px;
}

.run-row {
  display: grid;
  grid-template-columns: 90px 90px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  background: #fafbfc;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.summary-grid div {
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  padding: 12px;
  background: #fafbfc;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.summary-grid strong {
  font-size: 18px;
}

@media (max-width: 900px) {
  .topbar,
  .section-header,
  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    height: auto;
    padding: 14px 16px;
  }

  .shell {
    width: min(100% - 20px, 1360px);
    margin-top: 14px;
  }

  .add-form {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .summary-strip {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .summary-strip {
    margin-left: 0;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .run-row {
    grid-template-columns: 1fr;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .user-chip-name {
    display: none;
  }
}

/* ===== Đăng nhập ===== */
.auth-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 12% -8%, #e8effb 0%, rgba(232, 239, 251, 0) 60%),
    radial-gradient(900px 480px at 100% 0%, #eaf6ef 0%, rgba(234, 246, 239, 0) 55%),
    var(--bg);
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.auth-card {
  width: 100%;
  max-width: 412px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.1);
  padding: 32px 30px 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand .brand-mark {
  width: 40px;
  height: 40px;
  font-size: 13px;
}

.auth-brand strong {
  display: block;
  font-size: 15px;
}

.auth-brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.auth-title {
  font-size: 22px;
  margin: 0 0 4px;
}

.auth-sub {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 13.5px;
}

.auth-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid #f0b9b9;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-form {
  display: grid;
  gap: 15px;
}

.auth-field span {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.auth-pass {
  position: relative;
  display: block;
}

.auth-pass input {
  padding-right: 62px;
}

.auth-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 5px;
}

.auth-eye:hover {
  background: #f0f5ff;
}

.auth-submit {
  width: 100%;
  min-height: 42px;
  margin-top: 4px;
  font-size: 14px;
}

.auth-foot {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 22px 0 0;
}

.auth-links {
  text-align: center;
  margin: 16px 0 0;
  font-size: 13px;
}

.auth-note {
  background: #eef4ff;
  border: 1px solid #cfe0ff;
  color: #1f3d7a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 16px;
}

.auth-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: rgba(31, 61, 122, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ===== Trang tài khoản ===== */
.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.account-id {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-id strong {
  display: block;
}

.account-id small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.account-avatar,
.user-chip-avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.account-avatar {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label span {
  font-weight: 600;
  color: var(--text);
}

.field-hint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

/* ===== Topbar: menu người dùng ===== */
.topbar-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
  margin: 0 2px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
}

.user-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.user-chip-avatar {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.user-chip-name {
  font-size: 13px;
  font-weight: 600;
}
