:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --blue: #4338ca;
  --blue-soft: #e0e7ff;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: 
    radial-gradient(circle at 0% 0%, rgba(67, 56, 202, 0.08), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.05), transparent 40%),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  padding: 48px 40px;
  background: var(--panel);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), #f59e0b);
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-radius: 12px;
}

.login-panel h1 {
  margin: 20px 0 8px;
  font-size: 26px;
}

.login-panel p,
.topbar p {
  margin: 0;
  color: var(--muted);
}

.login-panel label {
  display: block;
  margin-top: 18px;
}

.login-panel label span,
.field label {
  display: block;
  margin-bottom: 8px;
  color: #475569;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f8fafc;
  outline: none;
  transition: all 0.2s ease;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.primary,
.ghost,
.danger,
.soft {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 700;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #3730a3);
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.2);
}

.primary:hover {
  box-shadow: 0 6px 16px rgba(67, 56, 202, 0.3);
  transform: translateY(-1px);
}

.ghost {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.ghost:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.soft {
  color: var(--blue);
  background: var(--blue-soft);
}

.soft:hover {
  background: #c7d2fe;
}

.danger {
  color: #fff;
  background: linear-gradient(135deg, var(--red), #b91c1c);
}

.danger:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
  transform: translateY(-1px);
}

.login-panel .primary {
  width: 100%;
  margin-top: 24px;
}

.error {
  min-height: 22px;
  margin-top: 12px;
  color: var(--red);
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar {
  min-height: 100vh;
  padding: 24px 16px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
  white-space: nowrap;
  overflow: hidden;
}

.brand strong,
.brand span,
.brand-text {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  color: #64748b;
  text-align: left;
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  color: #0f172a;
  background: #f1f5f9;
}

.nav-item.active {
  color: var(--blue);
  background: var(--blue-soft);
}

/* --- 折叠状态样式 --- */
.app-view.collapsed {
  grid-template-columns: 80px 1fr;
}

.app-view.collapsed .sidebar {
  padding: 24px 12px;
}

/* 折叠时隐藏文字内容 */
.app-view.collapsed .brand-text,
.app-view.collapsed .brand strong,
.app-view.collapsed .brand span,
.app-view.collapsed .nav-item span {
  display: none;
}

.app-view.collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

.main {
  min-width: 0;
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.topbar h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  padding: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card,
.panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid #f1f5f9;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 500;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel {
  margin-top: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
}

.toolbar {
  display: flex;
  gap: 10px;
}

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

th,
td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef2f7;
}

th {
  color: #475569;
  font-weight: 700;
  background: #f8fafc;
}

tbody tr {
  transition: background-color 0.2s ease;
}
tbody tr:hover {
  background-color: #f8fafc;
}

td.actions {
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 700;
}

.tag.green {
  color: var(--green);
  background: #dcfce7;
}

.tag.amber {
  color: #b45309;
  background: #fef3c7;
}

.tag.red {
  color: var(--red);
  background: #fee2e2;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: #f1f5f9;
  font-size: 22px;
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
}

.field.full {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

@media (max-width: 900px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .stats-grid,
  .form {
    grid-template-columns: 1fr;
  }
}
