:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --border: #e6e8ef;
  --text: #253045;
  --muted: #72809b;
  --brand: #2f6dff;
  --brand-soft: #edf3ff;
  --danger: #e44f5f;
  --success: #2d9f6d;
  --warning: #d08700;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #111827;
  color: #d5def1;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.logo {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}

.menu-item {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #aeb8cf;
  margin-bottom: 4px;
}

.menu-item:hover,
.menu-item.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.content {
  padding: 24px;
  display: grid;
  gap: 16px;
}

.content-head h1 {
  margin: 0;
  font-size: 26px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.stats-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.stat-item {
  background: var(--brand-soft);
  border: 1px solid #dce8ff;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.stat-item b {
  font-size: 24px;
  color: var(--brand);
}

.table-wrap {
  overflow: auto;
}

.table-image-thumb {
  width: 56px;
  height: 42px;
  border-radius: 6px;
  border: 1px solid #e2e8f3;
  object-fit: cover;
  display: block;
}

.table-wrap td img {
  max-width: 56px;
  max-height: 42px;
  height: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 780px;
}

th, td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 10px 8px;
  font-size: 14px;
  vertical-align: top;
}

th {
  font-weight: 700;
  color: #3a4760;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

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

label span {
  color: #4a5874;
}

input[type='text'],
input[type='password'],
input[type='number'],
select,
textarea {
  width: 100%;
  border: 1px solid #d8dfea;
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
}

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #3f4f6f;
}

.form-image-preview {
  width: 96px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid #dde4f0;
  overflow: hidden;
  background: #f8fafc;
}

.form-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.form-image-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.search-form {
  margin-top: 10px;
}

.toolbar-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid #d3d9e7;
  background: #fff;
  color: #32415d;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover {
  opacity: 0.92;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-light {
  background: #f8f9fc;
}

.btn-danger {
  background: #fff5f6;
  border-color: #ffd8dc;
  color: var(--danger);
}

.alert {
  margin: 10px 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.alert-success {
  background: #ecfbf4;
  color: var(--success);
  border: 1px solid #bdeacf;
}

.alert-error {
  background: #fff4f5;
  color: var(--danger);
  border: 1px solid #ffd5da;
}

.login-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top right, #e6ecff 0%, #f7f8fb 50%, #f7f8fb 100%);
}

.login-card {
  width: min(420px, 92vw);
  background: #fff;
  border: 1px solid #e2e7f0;
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(18, 33, 66, 0.08);
  padding: 24px;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.tip {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

body.modal-open {
  overflow: hidden;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(17, 24, 39, 0.42);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-mask.show {
  display: flex;
}

.modal-card {
  width: min(860px, 96vw);
  max-height: 88vh;
  background: #fff;
  border: 1px solid #e1e7f0;
  border-radius: 14px;
  box-shadow: 0 18px 46px rgba(20, 36, 78, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 10px;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sidebar-foot {
    margin-top: 6px;
  }

  .content {
    padding: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .modal-mask {
    padding: 10px;
  }

  .modal-card {
    width: 100%;
    max-height: 92vh;
  }
}
