:root {
  --brand: #00b357;
  --brand-dark: #099a4c;
  --brand-soft: #e8f8ed;
  --bg: #f0f2f5;
  --side: #14201a;
  --side-text: #a8b8af;
  --text: #1f2329;
  --muted: #8a9199;
  --card: #ffffff;
  --line: #e5e8eb;
  --danger: #e5484d;
  --danger-soft: #ffe8e8;
  --warn: #f5a623;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 20, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }
img { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { font: inherit; }
code {
  background: #f3f5f7;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: #444;
}

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.side {
  width: 232px;
  background: linear-gradient(180deg, #16261e 0%, var(--side) 100%);
  color: var(--side-text);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .logo {
  padding: 22px 20px 18px;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.side .logo span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  color: #7f9488;
}
.side nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.side .nav-group {
  margin: 14px 10px 6px;
  font-size: 11px;
  color: #6d8076;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.side nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 2px;
  color: var(--side-text);
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.side nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side nav a.active {
  background: rgba(0, 179, 87, 0.22);
  color: #fff;
  font-weight: 600;
}
.side .side-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #6d8076;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-title { font-size: 15px; font-weight: 600; color: var(--text); }
.top-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.top-user a {
  color: var(--brand-dark);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--brand-soft);
}
.content { padding: 20px 24px 48px; flex: 1; }

/* ===== Cards / Stats ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.02);
}
.card + .card { margin-top: 16px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0, 0, 0, 0.02);
}
.stat .n {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand-dark);
  line-height: 1.2;
}
.stat .l {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

h1 { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
h2.section-title {
  margin: 20px 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #333;
}

/* ===== Toolbar / Buttons ===== */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar.tight { margin-bottom: 0; }
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  flex: 1;
}
.filter-bar input,
.filter-bar select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 140px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: var(--brand);
  color: #fff !important;
  line-height: 1;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn-ghost {
  background: var(--brand-soft);
  color: var(--brand-dark) !important;
}
.btn-ghost:hover { background: #d8f3e3; }
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger) !important;
}
.btn-danger:hover { background: #ffd4d4; }
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 6px;
}
.btn-block { width: 100%; height: 42px; font-size: 15px; }

/* ===== Table ===== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
table.data th,
table.data td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
table.data th {
  color: #667085;
  font-weight: 600;
  background: #f8faf9;
  white-space: nowrap;
}
table.data tbody tr:hover { background: #fafcfb; }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-name { font-weight: 600; color: var(--text); }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.actions form { margin: 0; display: inline; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}
.badge-on { background: var(--brand-soft); color: var(--brand-dark); }
.badge-off { background: #f2f3f5; color: #888; }
.badge-type { background: #eef3ff; color: #3b6de0; }

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: #f5f6f7;
  border: 1px solid var(--line);
}
.thumb-lg {
  width: 80px;
  height: 80px;
  border-radius: 10px;
}

/* ===== Forms ===== */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
  font-weight: 500;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  max-width: none;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-row textarea {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 179, 87, 0.12);
}
.form-row input[type="file"] {
  height: auto;
  padding: 8px 0;
  border: none;
  box-shadow: none;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
  max-width: 920px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 8px;
}
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.hint.mt { margin-top: 6px; }
.ok {
  background: var(--brand-soft);
  color: #0a7a3c;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}
.preview-box { margin-top: 10px; }

.row-item {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px 4px;
  margin-bottom: 10px;
}

/* ===== Login ===== */
.login-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 179, 87, 0.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0, 179, 87, 0.08), transparent 42%),
    linear-gradient(160deg, #eaf8f0 0%, #f5f6fa 55%, #eef2f6 100%);
}
.login-box {
  width: 380px;
  max-width: calc(100% - 32px);
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px 28px;
  box-shadow: 0 16px 40px rgba(20, 40, 30, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.03);
}
.login-box h1 { margin: 0 0 6px; font-size: 22px; }
.login-box .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-box .err {
  background: var(--danger-soft);
  color: #c62828;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
.login-box label {
  display: block;
  font-size: 13px;
  margin: 12px 0 6px;
  color: #555;
  font-weight: 500;
}
.login-box input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
.login-box input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 179, 87, 0.12);
}

@media (max-width: 960px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .side { display: none; }
  .content { padding: 16px; }
  .stats { grid-template-columns: 1fr; }
}
