* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f8;
  color: #1f2937;
}

a {
  color: #4f6ef7;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: #4f6ef7;
  color: #fff;
}

.btn-ghost {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #374151;
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

.input,
.select,
.textarea {
  font-family: inherit;
  font-size: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.input,
.select {
  height: 36px;
  padding: 0 12px;
}

.textarea {
  width: 100%;
  padding: 10px 12px;
  resize: vertical;
}

.table-wrap {
  background: #fff;
  border-radius: 12px;
  overflow: auto;
  box-shadow: 0 4px 20px rgba(79, 110, 247, 0.06);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  background: #f9fafb;
  color: #6b7280;
  font-weight: 600;
  white-space: nowrap;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.tag-ok {
  background: #dcfce7;
  color: #166534;
}

.tag-off {
  background: #fee2e2;
  color: #991b1b;
}

.tag-warn {
  background: #fef3c7;
  color: #92400e;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f6ef7, #6b4ce6);
}

.login-card {
  width: 380px;
  max-width: 92vw;
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

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

.login-card .sub {
  margin: 8px 0 24px;
  color: #6b7280;
  font-size: 14px;
}

.login-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.login-card .input {
  width: 100%;
  margin-bottom: 16px;
}

.login-card .btn-primary {
  width: 100%;
  height: 40px;
}

.login-error {
  margin-top: 12px;
  color: #dc2626;
  font-size: 13px;
}

/* Layout */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #1e293b;
  color: #e2e8f0;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 28px;
}

.sidebar .nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.sidebar .nav-item:hover,
.sidebar .nav-item.active {
  background: rgba(79, 110, 247, 0.25);
  color: #fff;
}

.sidebar .logout {
  margin-top: auto;
  background: transparent;
  border: 1px solid #475569;
  color: #cbd5e1;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.main {
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

.head h2 {
  margin: 0 0 6px;
}

.head p {
  margin: 0 0 20px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.6;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(79, 110, 247, 0.06);
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 120px;
  box-shadow: 0 4px 20px rgba(79, 110, 247, 0.06);
}

.stat-card.ok .stat-value {
  color: #059669;
}

.stat-label {
  display: block;
  font-size: 13px;
  color: #6b7280;
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: min(440px, 96vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.modal-wide {
  width: min(640px, 96vw);
}

.modal h3 {
  margin: 0 0 12px;
}

.modal-meta {
  margin: 0 0 16px;
  color: #6b7280;
  font-size: 14px;
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.content-cell {
  max-width: 280px;
  word-break: break-word;
  line-height: 1.45;
}

.actions {
  white-space: nowrap;
}

.actions .btn {
  margin: 0 4px 4px 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}

.tab-btn.active {
  background: #4f6ef7;
  border-color: #4f6ef7;
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.form-grid label .input,
.form-grid label .select,
.form-grid label .textarea {
  width: 100%;
}

@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .main {
    padding: 20px 16px;
  }
}
