* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --secondary: #64748b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #ea580c;
  --bg: #f8fafc;
  --bg-dark: #1e293b;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 20px 30px;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 5px;
}

header .subtitle {
  font-size: 14px;
  opacity: 0.9;
}

.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─────────────────────────────────────────────────────────── */
/* 侧边栏 */
/* ─────────────────────────────────────────────────────────── */

.sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.sidebar h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.table-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-btn:hover {
  background: #f1f5f9;
  border-left-color: var(--primary);
}

.nav-btn.active {
  background: var(--primary);
  color: white;
  border-left-color: var(--primary);
  font-weight: 500;
}

/* ─────────────────────────────────────────────────────────── */
/* 内容区 */
/* ─────────────────────────────────────────────────────────── */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: var(--danger);
  color: white;
}

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

.filter-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

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

/* ─────────────────────────────────────────────────────────── */
/* 表格 */
/* ─────────────────────────────────────────────────────────── */

.table-wrapper {
  flex: 1;
  overflow: auto;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.data-table thead {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
}

.col-resizer:hover {
  background: var(--primary);
  opacity: 0.5;
}

.col-resizer:active {
  background: var(--primary);
  opacity: 0.8;
}

.data-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
}

.data-table td.cell-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
  cursor: help;
}

.data-table td.title-cell {
  cursor: default;
}

.data-table tbody tr:hover {
  background: #fafbfc;
}

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

.data-table .status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.active {
  background: #dcfce7;
  color: #166534;
}

.status-badge.inactive {
  background: #fee2e2;
  color: #7f1d1d;
}

.status-badge.pending {
  background: #fef3c7;
  color: #92400e;
}

/* 表格行操作 */
.row-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 10px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.edit {
  background: #dbeafe;
  color: var(--primary);
}

.action-btn.edit:hover {
  background: var(--primary);
  color: white;
}

.action-btn.delete {
  background: #fee2e2;
  color: var(--danger);
}

.action-btn.delete:hover {
  background: var(--danger);
  color: white;
}

/* ─────────────────────────────────────────────────────────── */
/* 状态提示 */
/* ─────────────────────────────────────────────────────────── */

.loading,
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 16px;
}

/* ─────────────────────────────────────────────────────────── */
/* 模态框 */
/* ─────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-light);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

/* 表单 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

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

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

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

/* ─────────────────────────────────────────────────────────── */
/* 提示信息 */
/* ─────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  background: var(--text);
  color: white;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

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

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

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

/* ─────────────────────────────────────────────────────────── */
/* 响应式 */
/* ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 150px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .table-nav {
    flex-direction: row;
    gap: 12px;
  }

  .nav-btn {
    padding: 8px 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .modal-content {
    width: 95%;
  }

  .data-table td {
    max-width: 100px;
    font-size: 12px;
  }
}
