/* ============================================================
   Layout — login, app shell, navigation, page structure
   ============================================================ */

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-10) var(--sp-8);
}
.login-logo {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  margin-bottom: var(--sp-5);
}
.login-hint {
  margin-top: var(--sp-5);
  padding: var(--sp-3);
  background: var(--slate-50);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.login-hint code { white-space: nowrap; }

/* ---------- App shell ---------- */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-sidebar);
  color: var(--slate-300);
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow-y: auto;
  transition: transform 0.2s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-height);
  padding: 0 var(--sp-5);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.sidebar-brand .logo-mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.sidebar-nav { padding: var(--sp-4) 0; flex: 1; }
.nav-group { margin-bottom: var(--sp-4); }
.nav-group-title {
  padding: var(--sp-2) var(--sp-5);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500);
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-5);
  color: var(--slate-300);
  font-size: var(--fs-base);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nav-item:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-item.active {
  background: rgba(37, 99, 235, 0.18);
  border-left-color: var(--color-sidebar-active);
  color: #fff;
}
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }

.main-area { grid-column: 2; min-width: 0; }

/* Sidebar collapsed: hide the fixed sidebar and let the main area take full width */
body.sidebar-collapsed .app-layout { grid-template-columns: 0 1fr; }
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }

.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
}
.topbar-left { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.sidebar-toggle { font-size: 18px; line-height: 1; padding: 6px 10px; flex-shrink: 0; }
.topbar-title { font-size: var(--fs-md); font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: var(--sp-3); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 600;
}
.user-meta { line-height: 1.25; }
.user-meta .name { font-weight: 600; font-size: var(--fs-sm); }
.user-meta .role { font-size: var(--fs-xs); color: var(--color-text-muted); }

.content { padding: var(--sp-6); width: 100%; }

/* Global footer: copyright + ICP filing number */
.app-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.app-footer a { color: var(--color-text-muted); }
.app-footer a:hover { color: var(--color-primary); }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.page-header h1 { margin-bottom: var(--sp-1); }
.page-header .subtitle { color: var(--color-text-muted); font-size: var(--fs-sm); }
.page-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.card-header h2, .card-header h3 { font-size: var(--fs-md); }
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Stat cards */
.stat-card { padding: var(--sp-5); }
.stat-label { font-size: var(--fs-sm); color: var(--color-text-muted); margin-bottom: var(--sp-2); }
.stat-value { font-size: var(--fs-2xl); font-weight: 700; color: var(--slate-900); }
.stat-value.danger { color: var(--color-danger); }
.stat-value.success { color: var(--color-success); }
.stat-value.warning { color: var(--color-warning); }
.stat-foot { font-size: var(--fs-xs); color: var(--color-text-muted); margin-top: var(--sp-1); }

/* Detail description list */
.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: 0; }
.detail-list dt {
  padding: var(--sp-3) var(--sp-4);
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  background: var(--slate-50);
  border-bottom: 1px solid var(--color-border);
}
.detail-list dd {
  padding: var(--sp-3) var(--sp-4);
  margin: 0;
  border-bottom: 1px solid var(--color-border);
  word-break: break-word;
}

/* Timeline */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px;
  width: 2px; background: var(--slate-200);
}
.timeline-item { position: relative; padding-bottom: var(--sp-5); }
.timeline-item::before {
  content: ""; position: absolute; left: -22px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-primary); border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--slate-200);
}
.timeline-item .tl-meta { font-size: var(--fs-xs); color: var(--color-text-muted); margin-bottom: var(--sp-1); }
.timeline-item .tl-title { font-weight: 600; font-size: var(--fs-sm); }
