/* ===== CSS Variables ===== */
:root {
  --primary: #4A7BF7;
  --primary-light: #6B93FA;
  --primary-bg: #EEF2FE;
  --success: #34C38F;
  --success-bg: #E8F8F0;
  --warning: #FF9F43;
  --warning-bg: #FFF5E6;
  --danger: #F4516C;
  --danger-bg: #FEF0F2;
  --info: #57A3F7;

  --bg: #F5F7FA;
  --card: #FFFFFF;
  --text: #2D3436;
  --text-secondary: #636E72;
  --text-light: #A0A8B4;
  --border: #E8ECF1;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-width: 260px;
  --mobile-header-h: 52px;
  --mobile-nav-h: 60px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

/* ===== Sidebar (PC) ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* 一级导航项 */
.nav-group {
  margin-bottom: 2px;
}

.nav-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: none;
  text-align: left;
  transition: background 0.2s;
  user-select: none;
}

.nav-group-title:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-group-title.active {
  color: var(--primary);
  background: var(--primary-bg);
}

.nav-group-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-group-icon svg {
  width: 18px;
  height: 18px;
}

.nav-group-arrow {
  margin-left: auto;
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
  opacity: 0.4;
}

.nav-group-arrow.open {
  transform: rotate(90deg);
  opacity: 0.7;
}

/* 二级导航 - 分类标题 */
.nav-group-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-group-children.open {
  max-height: 800px;
}

.nav-subsection-title {
  padding: 8px 20px 4px 50px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 三级导航 - 页面链接 */
.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 20px 8px 50px;
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
  position: relative;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 32px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-light);
  transition: all 0.15s;
}

.nav-item:hover {
  color: var(--primary);
  background: var(--primary-bg);
}

.nav-item:hover::before {
  background: var(--primary);
}

.nav-item.active {
  color: var(--primary);
  font-weight: 500;
  background: var(--primary-bg);
}

.nav-item.active::before {
  background: var(--primary);
  width: 6px;
  height: 6px;
  left: 31px;
}

/* ===== Mobile Header ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.mobile-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ===== Mobile Bottom Nav ===== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 90;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  background: none;
  color: var(--text-light);
  flex: 1;
  cursor: pointer;
}

.mobile-nav-item:active {
  background: var(--primary-bg);
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-icon {
  width: 22px;
  height: 22px;
}

.mobile-nav-label {
  font-size: 10px;
  font-weight: 500;
}

/* ===== Mobile Submenu Panel ===== */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 200;
}

.mobile-overlay.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

.mobile-submenu {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 210;
  flex-direction: column;
  overflow: hidden;
}

.mobile-submenu.show {
  display: flex;
  animation: slideUp 0.3s ease;
}

.mobile-submenu-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.mobile-submenu-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.mobile-submenu-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
}

.mobile-submenu-body {
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}

.mobile-subsection {
  padding: 4px 0;
}

.mobile-subsection-label {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
}

.mobile-submenu-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  font-size: 14px;
  color: var(--text);
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
  border: none;
}

.mobile-submenu-item:active {
  background: var(--primary-bg);
}

.mobile-submenu-item.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-bg);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 24px;
  min-height: 100vh;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.page-title-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

/* ===== Breadcrumb ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--text-light);
  transition: color 0.15s;
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb-sep {
  font-size: 10px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(74, 123, 247, 0.3);
}

.btn-outline {
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--primary);
}

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

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  padding: 6px 10px;
}

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

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

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ===== Card ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  font-size: 13px;
}

.data-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--primary-bg);
}

/* ===== Status Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: rgba(87, 163, 247, 0.1);
  color: var(--info);
}

.badge-default {
  background: var(--bg);
  color: var(--text-secondary);
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.info-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: all 0.2s;
}

.info-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.info-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.info-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
  font-size: 20px;
  font-weight: 600;
}

.info-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.info-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.info-card-role {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.info-card-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-card-detail {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.info-card-detail svg {
  width: 14px;
  height: 14px;
  color: var(--text-light);
  flex-shrink: 0;
}

/* ===== Equipment Card ===== */
.equip-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.2s;
}

.equip-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.equip-card-img {
  height: 140px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 13px;
}

.equip-card-img svg {
  width: 40px;
  height: 40px;
  color: var(--border);
}

.equip-card-body {
  padding: 14px 16px;
}

.equip-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.equip-card-model {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.equip-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===== Dashboard / Kanban ===== */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.kanban-column {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kanban-column-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-count {
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 100px;
  font-weight: 600;
}

.kanban-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.kanban-card:last-child {
  margin-bottom: 0;
}

.kanban-card-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.kanban-card-meta {
  font-size: 11px;
  color: var(--text-light);
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-tag {
  padding: 5px 14px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  background: var(--card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-tag.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== Week Schedule Table ===== */
.week-schedule {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.week-schedule-cell {
  background: var(--card);
  padding: 12px;
  text-align: center;
  font-size: 13px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.week-schedule-header {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
}

.week-schedule-label {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 12px;
  justify-content: flex-start;
  padding-left: 14px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 14px;
}

/* ===== Responsive ===== */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .mobile-header {
    display: flex;
  }

  .mobile-nav {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: calc(var(--mobile-header-h) + 12px) 14px
      calc(var(--mobile-nav-h) + 12px);
    min-height: 100vh;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-title {
    font-size: 17px;
  }

  .page-actions {
    width: 100%;
  }

  .btn {
    padding: 7px 12px;
    font-size: 12px;
  }

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

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

  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-tag {
    flex-shrink: 0;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 8px 10px;
    font-size: 12px;
  }

  .week-schedule {
    grid-template-columns: 60px repeat(7, 1fr);
    font-size: 12px;
  }

  .week-schedule-cell {
    padding: 8px 4px;
    min-height: 40px;
  }
}

/* ===== Misc ===== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.gap-sm {
  gap: 8px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.mt-sm {
  margin-top: 8px;
}

.mb-sm {
  margin-bottom: 8px;
}
