/* wylTools — 企业级设计令牌（Data-Dense Dashboard + 大厂交付标准） */
:root {
  --font-sans: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --font-mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-primary: #7c3aed;
  --color-primary-hover: #6d28d9;
  --color-primary-soft: #f5f3ff;
  --color-cta: #f97316;
  --color-sidebar: #1e1b4b;
  --color-sidebar-hover: rgba(255, 255, 255, 0.08);
  --color-sidebar-active: rgba(124, 58, 237, 0.35);
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  --color-success-text: #065f46;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-danger-text: #991b1b;
  --sidebar-width: 260px;
  --topbar-height: 56px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
}

.font-mono { font-family: var(--font-mono); }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: #f8fafc !important;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.app-sidebar-logo:hover { color: #fff !important; }

.app-sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.45);
}

.app-sidebar-env {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a5b4fc;
}

.app-sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.6rem;
  overflow-y: auto;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #cbd5e1 !important;
  text-decoration: none !important;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.app-nav-link i {
  font-size: 1.05rem;
  opacity: 0.9;
  width: 1.25rem;
  text-align: center;
}

.app-nav-link:hover {
  background: var(--color-sidebar-hover);
  color: #f1f5f9 !important;
}

.app-nav-link.is-active {
  background: var(--color-sidebar-active);
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.35);
}

.app-sidebar-footer {
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  color: #a5b4fc;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-topbar-crumb {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted) !important;
  text-decoration: none !important;
  cursor: pointer;
  transition: color 0.2s ease;
}

.app-topbar-crumb:hover { color: var(--color-primary) !important; }

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--color-text-secondary) !important;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text) !important;
}

.app-content {
  flex: 1;
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Auth pages */
.app-auth-outer {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, 0.12), transparent 50%),
    radial-gradient(800px 400px at 90% 100%, rgba(249, 115, 22, 0.08), transparent 45%),
    linear-gradient(180deg, #faf5ff 0%, #eef2f7 100%);
}

.app-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.app-alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success-text);
}

.app-alert-danger {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger-text);
}

.app-alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.app-alert i { margin-top: 0.1rem; flex-shrink: 0; }

/* Panels */
.app-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.app-panel + .app-panel { margin-top: 1.25rem; }

.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.filter-toolbar .form-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* Tables */
.table.data-table {
  margin-bottom: 0;
  font-size: 0.875rem;
  vertical-align: middle;
}

.table.data-table thead th {
  background: var(--color-surface-2) !important;
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border) !important;
  padding: 0.65rem 1rem;
  white-space: nowrap;
}

.table.data-table tbody td {
  padding: 0.65rem 1rem;
  border-color: var(--color-border) !important;
}

.table.data-table tbody tr {
  transition: background 0.15s ease;
}

.table.data-table tbody tr:hover { background: #fafbfc; }

.table.data-table a:not(.btn) {
  color: var(--color-primary);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.table.data-table a:not(.btn):hover { text-decoration: underline; }

/* Buttons */
.btn-primary {
  --bs-btn-bg: var(--color-primary);
  --bs-btn-border-color: var(--color-primary);
  --bs-btn-hover-bg: var(--color-primary-hover);
  --bs-btn-hover-border-color: var(--color-primary-hover);
  --bs-btn-focus-shadow-rgb: 124, 58, 237;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-outline-secondary {
  border-color: var(--color-border-strong);
  color: var(--color-text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-outline-secondary:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-link { cursor: pointer; }

/* Forms */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-border-strong);
  font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-label {
  font-weight: 500;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.form-check-input:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

/* Page header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.page-header .text-muted {
  color: var(--color-text-muted) !important;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Login */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 960px;
  width: 100%;
  min-height: 520px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.auth-split-brand {
  background: linear-gradient(145deg, #4c1d95 0%, #7c3aed 45%, #1e1b4b 100%);
  color: #ede9fe;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-brand-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #e9d5ff;
  margin-bottom: 1rem;
  width: fit-content;
}

.auth-split-brand h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: #fff;
  letter-spacing: -0.03em;
}

.auth-split-brand p {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  opacity: 0.88;
  line-height: 1.65;
}

.auth-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.auth-feature-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.auth-feature-list i { color: #c4b5fd; }

.auth-split-form {
  padding: 2.5rem 2.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-form-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}

.auth-form-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.auth-card {
  max-width: 420px;
  width: 100%;
  padding: 2.5rem 2rem;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}

.auth-card-icon { font-size: 3rem; }

/* Stats */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.stat-card .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}

/* Badges */
.badge-status-on {
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.badge-status-off {
  background: #f1f5f9;
  color: #64748b;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.badge-role-admin {
  background: var(--color-primary-soft);
  color: #5b21b6;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.badge-role-user {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

/* Responsive */
@media (max-width: 767.98px) {
  .auth-split {
    grid-template-columns: 1fr;
    min-height: unset;
  }
  .auth-split-brand { padding: 1.75rem 1.5rem; }
}

@media (max-width: 991.98px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    position: relative;
    width: 100%;
    min-height: unset;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.5rem;
  }
  .app-sidebar-brand { border: none; padding: 0.5rem 0.75rem; flex: 1; }
  .app-sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    padding: 0.25rem;
    gap: 0.15rem;
  }
  .app-nav-link span { display: none; }
  .app-nav-link { padding: 0.5rem; justify-content: center; }
  .app-sidebar-footer { display: none; }
}
