:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e1e4e8;
  --color-text: #1f2328;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 14px;
}

.home-link {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
  padding-top: 4px;
}

.home-link:hover {
  text-decoration: underline;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}

.card + .card {
  margin-top: 20px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.hint {
  color: var(--color-text-muted);
  font-size: 12px;
  margin: 6px 0 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: #eef2ff;
  color: var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: #dce4fd;
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--color-success);
  color: #fff;
}

.btn-small-secondary {
  padding: 6px 12px;
  font-size: 13px;
  background: #eef2ff;
  color: var(--color-primary);
}

.btn-small-secondary:hover {
  background: #dce4fd;
}

.btn-small-danger {
  padding: 6px 12px;
  font-size: 13px;
  background: #fee2e2;
  color: var(--color-error);
}

.btn-small-danger:hover {
  background: #fecaca;
}

/* Nút icon-only cho các hành động trong bảng (copy link/sửa/bật-tắt/xoá) — thay cho nút chữ
   dài để bảng không bị bể layout khi nhiều cột/nhiều hành động cạnh nhau (xem public/icons.js). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: #eef2ff;
  color: var(--color-primary);
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: #dce4fd;
}

.icon-btn-danger {
  background: #fee2e2;
  color: var(--color-error);
}

.icon-btn-danger:hover {
  background: #fecaca;
}

.link-button {
  flex-shrink: 0;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
  background: #eef2ff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.link-button:hover {
  background: #dce4fd;
}

.error-text {
  color: var(--color-error);
  font-size: 14px;
  margin: 12px 0 0;
}

.success-text {
  color: var(--color-success);
  font-size: 14px;
  margin: 12px 0 0;
}

.action-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.login-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.microsoft-signin-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px;
  background: #fff;
  border: 1px solid #8c8c8c;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #5e5e5e;
  cursor: pointer;
}

.microsoft-signin-button:hover:not(:disabled) {
  background: #f3f3f3;
}

.microsoft-signin-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.microsoft-signin-button .ms-logo {
  flex-shrink: 0;
}

.microsoft-signin-button-small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.microsoft-signin-button-small .ms-logo {
  width: 15px;
  height: 15px;
}



.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: #f4f6fb;
  border-radius: var(--radius);
}

.user-bar[hidden] {
  display: none;
}

.user-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  flex: 1;
}

.role-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  background: #e0e7ff;
  border-radius: 999px;
  padding: 2px 8px;
  text-transform: uppercase;
}

.field input[type='text'],
.field input[type='password'],
.field input[type='email'],
.field input[type='url'],
.field input[type='file'] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-surface);
}

.field input[type='text']:focus,
.field input[type='password']:focus,
.field input[type='email']:focus,
.field input[type='url']:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--color-surface);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
}

.checkbox-label-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 13px;
  cursor: pointer;
}

/* Bọc <table> để cuộn ngang khi không đủ chỗ, thay vì để trình duyệt bóp cột "Hành động" tới mức phải
   xuống dòng (flex-wrap) — cột đó cần đứng nguyên 1 hàng bất kể bề rộng khung nhìn thật tế lúc deploy
   (khác máy dev, độ dài link đích...) hẹp hơn lúc test local. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 14px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

.data-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
}

.data-table td.role-admin {
  color: var(--color-primary);
  font-weight: 600;
}

.data-table .actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.short-link {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--color-primary);
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.is-active {
  background: #dcfce7;
  color: #15803d;
}

.status-pill.is-disabled {
  background: #fee2e2;
  color: #b91c1c;
}

.lock-badge {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Modal dùng chung cho popup tuỳ biến (sửa shortlink, đổi mật khẩu...) thay cho window.prompt/confirm
   có sẵn của trình duyệt — không đồng bộ style với phần còn lại của trang và không tuỳ biến được layout. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 420px;
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.modal .action-row {
  margin-top: 18px;
}

.confirm-message {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
}
