:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --bg: #F8FAFC;
  --card-bg: #FFFFFF;
  --text: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --border: #E2E8F0;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --sidebar-bg: #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #2563EB;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 48px 40px;
  width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 24px;
  color: var(--text);
  margin-bottom: 8px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
}

.login-card .el-input {
  height: 44px;
}

.login-card .el-button--primary {
  height: 44px;
  font-size: 15px;
  font-weight: 600;
}

.device-checking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: #F1F5F9;
  border-radius: 10px;
  margin-bottom: 20px;
  color: #64748B;
  font-size: 13px;
}

.device-checking .el-icon {
  font-size: 16px;
}

/* 设备信息框 */
.device-info-box {
  background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.device-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed #CBD5E1;
}

.device-info-header .el-icon {
  font-size: 18px;
  color: #2563EB;
}

.device-info-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-id-row .label {
  font-size: 12px;
  color: #64748B;
  font-weight: 500;
}

.device-id-row .device-id {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #2563EB;
  background: #EFF6FF;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.device-details {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #94A3B8;
}

.device-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 12px;
  width: fit-content;
}

.device-status-tag .el-icon {
  font-size: 12px;
}

.device-status-tag.registered {
  background: #DCFCE7;
  color: #16A34A;
}

.device-status-tag.unregistered {
  background: #FEF3C7;
  color: #D97706;
}

.device-status-tag.super-admin {
  background: linear-gradient(135deg, #FEF3C7 0%, #FCE7F3 100%);
  color: #9D174D;
  border: 1px solid #FBCFE8;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header h2 {
  color: white;
  font-size: 18px;
  font-weight: 600;
}

.sidebar-header p {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 12px;
}

.sidebar-menu .menu-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.2s;
  color: var(--sidebar-text);
  text-decoration: none;
}

.sidebar-menu .menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.sidebar-menu .menu-item.active {
  background: var(--sidebar-active);
  color: white;
}

.sidebar-menu .menu-item .icon {
  margin-right: 12px;
  font-size: 18px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left h3 {
  font-size: 16px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.page-header p {
  color: var(--text-secondary);
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 12px;
}

.stat-card .stat-icon.blue { background: #EFF6FF; color: var(--primary); }
.stat-card .stat-icon.green { background: #ECFDF5; color: var(--success); }
.stat-card .stat-icon.orange { background: #FFF7ED; color: var(--warning); }
.stat-card .stat-icon.red { background: #FEF2F2; color: var(--danger); }

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

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

.toolbar .spacer { flex: 1; }

.role-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.role-tag.superadmin { background: #FCE7F3; color: #9D174D; }
.role-tag.admin { background: #FEF3C7; color: #92400E; }
.role-tag.reception { background: #DBEAFE; color: #1E40AF; }

.status-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.status-tag.enabled { background: #D1FAE5; color: #065F46; }
.status-tag.disabled { background: #FEE2E2; color: #991B1B; }

.table-actions {
  display: flex;
  gap: 8px;
}

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

.permission-group {
  margin-bottom: 20px;
}

.permission-group-title {
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.permission-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.pagination-info {
  color: var(--text-secondary);
  font-size: 13px;
}

.log-detail {
  max-width: 500px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.el-table { --el-table-border-color: var(--border); }
.el-table th.el-table__cell { background: #F8FAFC !important; color: var(--text-secondary); font-weight: 600; }
.el-button--primary { background: var(--primary); border-color: var(--primary); }
.el-button--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ========== Timeline 时间轴房态 ========== */

.timeline-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.timeline-range {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.timeline-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
}

.timeline-container {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.timeline-empty {
  padding: 60px;
  text-align: center;
  color: var(--text-secondary);
}

.timeline-grid {
  display: flex;
  overflow: hidden;
}

/* ===== 左侧房间列表 ===== */
.timeline-rooms-col {
  width: 160px;
  min-width: 160px;
  background: #F8FAFC;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.timeline-rooms-header {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: #F1F5F9;
}

.timeline-room-row {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  transition: background 0.15s;
  gap: 8px;
}

.timeline-room-row:hover {
  background: #EFF6FF;
}

.timeline-room-row.selected {
  background: #DBEAFE;
  border-left: 3px solid var(--primary);
}

.room-no {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  min-width: 36px;
}

.room-floor {
  font-size: 11px;
  color: var(--text-secondary);
  flex: 1;
}

/* ===== 右侧日期列 ===== */
.timeline-dates-col {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-dates-header {
  display: flex;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: #F8FAFC;
  position: sticky;
  top: 0;
  z-index: 2;
}

.timeline-date-cell {
  min-width: 58px;
  width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #F1F5F9;
  font-size: 12px;
}

.timeline-date-cell.today {
  background: #EFF6FF;
}

.timeline-date-cell.weekend {
  background: #FEF2F2;
}

.timeline-date-cell.weekend.today {
  background: #DBEAFE;
}

.date-day {
  color: var(--text-secondary);
  font-size: 11px;
}

.date-num {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}

.today .date-num {
  color: var(--primary);
  background: #DBEAFE;
  border-radius: 10px;
  padding: 0 6px;
  line-height: 20px;
}

/* ===== 时间轴行 ===== */
.timeline-row-cells {
  display: flex;
  height: 52px;
  border-bottom: 1px solid #F1F5F9;
}

.timeline-cell {
  min-width: 58px;
  width: 58px;
  border-right: 1px solid #F5F5F5;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.timeline-cell:hover {
  background: #F0F7FF;
}

.timeline-cell.cell-weekend {
  background: #FFFBFB;
}

.timeline-cell.cell-today {
  border-left: 2px solid var(--primary);
}

/* 已入住 */
.timeline-cell.cell-occupied {
  background: #D1FAE5;
  cursor: pointer;
}

/* 已预订 */
.timeline-cell.cell-reserved {
  background: #DBEAFE;
  cursor: pointer;
}

/* 今日退房 */
.timeline-cell.cell-checkout {
  background: #FEF3C7;
  cursor: pointer;
}

/* 预订块的首尾圆角 */
.timeline-cell.cell-first.cell-reserved {
  border-radius: 6px 0 0 6px;
  margin-left: 2px;
}

.timeline-cell.cell-last.cell-reserved {
  border-radius: 0 6px 6px 0;
  margin-right: 2px;
}

.timeline-cell.cell-first.cell-occupied {
  border-radius: 6px 0 0 6px;
  margin-left: 2px;
}

.timeline-cell.cell-last.cell-occupied {
  border-radius: 0 6px 6px 0;
  margin-right: 2px;
}

/* 选择状态 */
.timeline-cell.cell-selecting {
  background: #A7F3D0;
  border: 1px dashed #10B981;
}

.timeline-cell.cell-range-hover {
  background: #D1FAE5;
  opacity: 0.7;
}

/* 预订标签 */
.booking-label {
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52px;
}

.cell-occupied .booking-label {
  background: #059669;
}

.quick-actions {
  display: flex;
  gap: 8px;
}

/* Logo icon */
.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-right: 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
}

/* User details */
.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.user-details .username {
  font-weight: 600;
  font-size: 14px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #FEF3C7 0%, #FCE7F3 100%);
  border: 1px solid #FBCFE8;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #9D174D;
}

.device-id-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.device-id-display:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.device-id-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}

.device-id-value {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  word-break: break-all;
  letter-spacing: 0.3px;
}

/* Table actions alignment */
.table-actions .el-button {
  padding: 4px 8px;
}

/* Improved card header */
.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* Better stat card hover */
.stat-card {
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Scrollbar styling */
.content::-webkit-scrollbar {
  width: 8px;
}

.content::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 4px;
}

.content::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.content::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Sidebar menu scrollbar */
.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
}

.empty-state .el-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* Improved form styles */
.el-form-item {
  margin-bottom: 16px;
}

/* Table improvements */
.el-table .el-table__cell {
  padding: 10px 0;
}

/* Button group improvements */
.el-button + .el-button {
  margin-left: 8px;
}
