/* 码商通管理后台 */
:root {
  --bg: #f5f6f8;
  --card: #fff;
  --ink: #1f1f1f;
  --muted: #8c8c8c;
  --line: #ebebeb;
  --line-dark: #d9d9d9;
  --brand: #06ae56;
  --brand-hover: #059a4c;
  --brand-soft: #edf9f1;
  --sidebar: #1a1f1c;
  --sidebar-text: #b8bfb9;
  --danger: #e54d42;
  --danger-soft: #fff2f0;
  --warn: #fa8c16;
  --warn-soft: #fff7e6;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.login-mark {
  width: 32px; height: 32px; border-radius: 4px; background: var(--brand);
  position: relative; flex-shrink: 0;
}
.login-mark::after {
  content: ''; position: absolute; inset: 6px;
  border: 2px solid #fff; border-radius: 1px;
}
.login-brand strong { font-size: 16px; font-weight: 600; }
.login-brand span { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.login-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* Form controls */
label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink);
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 14px;
  background: #fff;
  font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(6,174,86,0.12);
}
input:disabled { background: #fafafa; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .15s;
}
.btn:hover { background: var(--brand-hover); color: #fff; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-dark);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); background: #fff; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #cf3d32; color: #fff; }

/* Alerts */
.err {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #ffccc7;
}
.ok {
  background: var(--brand-soft);
  color: var(--brand-hover);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid #b7ebc6;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 20px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  padding: 4px 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-mark {
  width: 24px; height: 24px; border-radius: 3px; background: var(--brand);
  position: relative; flex-shrink: 0;
}
.sidebar-mark::after {
  content: ''; position: absolute; inset: 5px;
  border: 2px solid #fff; border-radius: 1px;
}
.sidebar-brand-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
}
.sidebar-brand-text span {
  font-size: 11px;
  color: #7a857e;
}
.nav-group {
  margin-bottom: 8px;
}
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: #9aa39c;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}
.nav-group-toggle:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.nav-group-title {
  letter-spacing: 0.04em;
  font-weight: 500;
}
.nav-group-arrow {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform .2s;
  flex-shrink: 0;
  margin-top: -2px;
}
.nav-group.is-open .nav-group-arrow {
  transform: rotate(-135deg);
  margin-top: 2px;
}
.nav-group-items {
  display: none;
  padding: 2px 0 4px;
}
.nav-group.is-open .nav-group-items {
  display: block;
}
.sidebar-nav a {
  display: block;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: 4px;
  margin-bottom: 2px;
  text-decoration: none;
  font-size: 13px;
  border-left: 2px solid transparent;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: rgba(6,174,86,0.12);
  color: #fff;
  border-left-color: var(--brand);
  text-decoration: none;
}
.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 12px;
  color: #6b736e;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.main-inner {
  flex: 1;
  padding: 20px 24px 32px;
  max-width: 1280px;
  width: 100%;
}

/* Stats */
.cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.stat-card a { color: inherit; text-decoration: none; }
.stat-card a:hover .value { color: var(--brand); }

/* Panel */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.panel:last-child { margin-bottom: 0; }
.panel-hd {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
  font-size: 14px;
  background: #fafafa;
}
.panel-hd a { font-size: 13px; font-weight: 400; }
.panel-body { padding: 16px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 500;
  background: #fafafa;
  font-size: 12px;
  white-space: nowrap;
}
tbody tr:hover td { background: #fafbfc; }
tr:last-child td { border-bottom: none; }
td code {
  font-size: 12px;
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  color: #595959;
}
td .actions { gap: 6px; }
td .actions form { display: inline-flex; margin: 0; }
td .actions .btn { margin: 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  background: var(--brand-soft);
  color: var(--brand-hover);
  border: 1px solid #b7ebc6;
  white-space: nowrap;
}
.badge.off { background: var(--danger-soft); color: var(--danger); border-color: #ffccc7; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #ffd591; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }

/* Forms */
.form-row { max-width: 480px; }
.form-grid { max-width: 520px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.form-actions .btn { margin-bottom: 0; }
.field-hint { margin: -10px 0 14px; font-size: 12px; color: var(--muted); }
.test-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
}
.test-result.ok {
  background: var(--brand-soft);
  color: var(--brand-hover);
  border: 1px solid #b7ebc6;
}
.test-result.err {
  background: var(--danger-soft);
  color: #8c2a22;
  border: 1px solid #ffccc7;
}
.test-result-msg { font-weight: 500; }
.test-result-fix {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0,0,0,0.08);
}
.test-result-fix strong {
  display: block;
  font-size: 12px;
  color: var(--ink);
  margin-bottom: 6px;
}
.test-result-fix-body {
  font-size: 12px;
  color: #595959;
  line-height: 1.7;
}

.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.search-bar input[type="text"] {
  margin: 0;
  max-width: 280px;
  flex: 1;
  min-width: 160px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.breadcrumb { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.breadcrumb a { color: var(--brand); }

.detail-dl {
  margin: 0;
  padding: 4px 16px 16px;
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.detail-dl dt { margin: 0; color: var(--muted); }
.detail-dl dd { margin: 0; word-break: break-all; }
.detail-label { margin: 12px 0 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.detail-label:first-child { margin-top: 0; }

.code-block {
  margin: 0;
  padding: 12px;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow: auto;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  background: #fafafa;
}
.pager-per {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  margin-right: 12px;
  color: var(--muted, #888);
  font-size: 13px;
}
.pager-per select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
}
.pager-links { display: flex; gap: 4px; align-items: center; }
.pager-links a,
.pager-links .current {
  display: inline-flex;
  min-width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0 8px;
  font-size: 13px;
}
.pager-links a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager-links .current { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-hover); font-weight: 500; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 120px;
  padding-top: 4px;
}
.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.bar-val { font-size: 11px; color: var(--muted); }
.bar-fill {
  width: 100%;
  max-width: 40px;
  background: var(--brand);
  border-radius: 3px 3px 0 0;
}
.bar-lbl { font-size: 11px; color: var(--muted); }

.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.08);
}

.storage-bar {
  height: 6px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}
.storage-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
}

.quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px;
}
.quick-links a {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  background: #fafafa;
}
.quick-links a:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
  text-decoration: none;
}

.empty-cell {
  text-align: center;
  padding: 32px 16px !important;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar-foot { display: none; }
  .main-inner { padding: 16px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-dl { grid-template-columns: 1fr; gap: 4px; }
  .topbar { padding: 0 16px; }
}
