:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.brand-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

/* Layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-logo {
  font-weight: 700;
  font-size: 16px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.nav-tab:hover {
  background: #f1f5f9;
  color: var(--text);
}

.nav-tab.active {
  background: #eff6ff;
  color: var(--primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-content {
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 19px;
}

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

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 5px;
  font-size: 13px;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-sm {
  width: auto !important;
  min-width: 160px;
  padding: 6px 10px !important;
  font-size: 13px !important;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-full {
  width: 100%;
}

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

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

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

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text);
}

.btn-icon {
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

/* Cards & Lists */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

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

.msg-sender {
  font-weight: 700;
  font-size: 15px;
}

.msg-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #eef2f7;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: #eff6ff;
  color: var(--primary);
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

.badge-green {
  background: #dcfce7;
  color: #15803d;
}

.badge-amber {
  background: #fef3c7;
  color: #b45309;
}

.badge-red {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.user-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.user-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
}

.user-check-item input[type="checkbox"] {
  width: auto;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  background: #f8fafc;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.actions-cell {
  display: flex;
  gap: 6px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
}

/* Grid & Code */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
}

.tip-line {
  margin: 0 0 14px;
  font-size: 13px;
}

.tip-line code {
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.preset-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

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

.modal-body {
  padding: 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* Toast */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  max-width: 340px;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}
