* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: #f5f7fb;
  color: #222;
  overflow: hidden;
}

a {
  text-decoration: none;
  color: inherit;
}

body {
  min-height: 100vh;
}

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* 侧边栏 */
.sidebar {
  width: 220px;
  background: #1f2937;
  color: #fff;
  padding: 24px 0;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
}

.sidebar .brand {
  font-size: 22px;
  font-weight: 700;
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

/* 兼容新的 partials-nav.ejs 结构 */
.sidebar .sidebar-header {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.sidebar .sidebar-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.sidebar .sidebar-user {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.72);
}

.sidebar .sidebar-user div + div {
  margin-top: 2px;
}

.sidebar .sidebar-nav {
  display: block;
}

.sidebar .sidebar-footer {
  margin-top: 16px;
}

.sidebar .nav-logout {
  color: #fca5a5;
}

.sidebar .nav-logout:hover {
  color: #fff;
  background: rgba(239, 68, 68, 0.18);
}

.sidebar a {
  display: block;
  padding: 14px 24px;
  color: rgba(255, 255, 255, 0.88);
  transition: all 0.2s ease;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar a.active {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
}

/* 右上角栏 */
.top-right-bar {
  position: fixed;
  top: 18px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  background: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.top-right-user {
  font-size: 14px;
  color: #333;
}

.btn-link {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #333;
  font-size: 14px;
  transition: all 0.2s ease;
}

.btn-link:hover {
  background: #e5e7eb;
}

.btn-logout-top {
  background: #ef4444;
  color: #fff;
}

.btn-logout-top:hover {
  background: #dc2626;
}

/* 主内容 */
.content,
.content-wrap {
  flex: 1;
  height: 100vh;
  padding: 88px 24px 24px;
  overflow-x: auto;
  overflow-y: auto;
  min-width: 0;
}

.content h1,
.content-wrap h1,
.page-title {
  margin: 0 0 20px;
  font-size: 30px;
  font-weight: 700;
  color: #111827;
}

.page-desc {
  margin: -6px 0 20px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.7;
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  color: #111827;
}

/* 表单 */
form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  color: #111827;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button,
.btn {
  display: inline-block;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover,
.btn:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #6b7280;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-danger {
  background: #ef4444;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: #10b981;
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: #f59e0b;
}

.btn-warning:hover {
  background: #d97706;
}

/* 表格 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  background: #fff;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
  line-height: 1.6;
}

th {
  background: #f9fafb;
  color: #111827;
  font-weight: 700;
  white-space: nowrap;
}

tr:hover td {
  background: #f8fbff;
}

.col-time {
  min-width: 170px;
}

.time-text {
  white-space: nowrap;
}

.muted-text {
  margin-top: 4px;
  color: #6b7280;
  font-size: 13px;
  word-break: break-all;
}

/* badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

.badge-gray {
  background: #e5e7eb;
  color: #374151;
}

.badge-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-yellow {
  background: #fef3c7;
  color: #92400e;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.pagination-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-link {
  display: inline-block;
  min-width: 36px;
  padding: 8px 12px;
  text-align: center;
  border-radius: 8px;
  background: #f3f4f6;
  color: #111827;
  font-size: 14px;
  transition: all 0.2s ease;
}

.page-link:hover {
  background: #e5e7eb;
}

.page-link.active {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
}

/* 提示信息 */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.stat-card .label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 30px;
  font-weight: 700;
  color: #111827;
}

/* 登录页 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.login-card h1 {
  margin: 0 0 18px;
  font-size: 28px;
  color: #111827;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card input {
  width: 100%;
}

/* 简单列表、信息块 */
.info-list {
  display: grid;
  gap: 12px;
}

.info-item {
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fafafa;
}

/* 操作按钮组 */
.action-group,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form {
  margin: 0;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* 平台配置页会复用的少量公共项 */
.meta-line {
  margin: 6px 0;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-all;
}

.form-grid {
  display: grid;
  grid-template-columns: 140px 1fr 140px 1fr;
  gap: 12px 16px;
  align-items: center;
  margin-top: 18px;
}

.form-grid label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  min-width: 0;
}

.status-valid {
  color: #15803d;
  font-weight: 700;
}

.status-expired {
  color: #b45309;
  font-weight: 700;
}

.status-login_failed {
  color: #dc2626;
  font-weight: 700;
}

.status-unknown {
  color: #6b7280;
  font-weight: 700;
}

/* 通用工具 */
.w-100 {
  width: 100%;
}

.text-muted {
  color: #6b7280;
}

.mt-0 {
  margin-top: 0;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-20 {
  margin-bottom: 20px;
}

/* 响应式 */
@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
  }

  .layout {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    height: auto;
    padding: 16px 0;
    position: static;
    overflow: visible;
  }

  .sidebar .brand,
  .sidebar .sidebar-header {
    padding: 0 16px 16px;
  }

  .sidebar a {
    padding: 12px 16px;
  }

  .content,
  .content-wrap {
    height: auto;
    overflow: visible;
    padding: 20px 16px 16px;
  }

  .top-right-bar {
    position: static;
    margin: 0 16px 16px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content h1,
  .content-wrap h1,
  .page-title {
    font-size: 24px;
  }

  form {
    flex-direction: column;
    align-items: stretch;
  }

  input[type="text"],
  input[type="password"],
  input[type="number"],
  select,
  textarea,
  button,
  .btn {
    width: 100%;
    min-width: 0;
  }

  .card {
    padding: 14px;
  }

  th,
  td {
    padding: 12px 10px;
    font-size: 13px;
  }

  .page-link {
    padding: 8px 10px;
    font-size: 13px;
  }

  .top-right-bar {
    gap: 8px;
  }
}
/* dialog modal */
.admin-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.admin-dialog.admin-dialog-wide {
  width: min(1180px, calc(100vw - 32px));
}

.admin-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.admin-dialog form {
  width: 100%;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.dialog-header h2 {
  margin: 0;
  font-size: 22px;
  color: #111827;
}

.dialog-close {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  background: #eef2f7;
  color: #374151;
  font-size: 22px;
  line-height: 1;
}

.dialog-close:hover {
  background: #e5e7eb;
}

button.admin-dialog-x {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #475569;
  font-size: 24px;
  line-height: 1;
}

button.admin-dialog-x:hover { background: #eef2f7; color: #0f172a; }
button.admin-dialog-x:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.line-dialog-title { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.line-dialog-title h2 { margin:0; }

.dialog-subtitle {
  padding: 12px 20px 0;
  color: #6b7280;
  font-size: 14px;
}

.admin-dialog .form-grid,
.admin-dialog .table-wrap,
.admin-dialog .dialog-actions,
.admin-dialog .dialog-inner-card {
  margin-left: 20px;
  margin-right: 20px;
}

.admin-dialog .form-grid {
  margin-top: 20px;
}

.admin-dialog .table-wrap {
  margin-top: 16px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}

.admin-dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 0 20px;
}

.dialog-inner-card {
  margin-top: 16px;
  margin-bottom: 20px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  box-shadow: none;
}

.modal-inline-form {
  flex-wrap: nowrap;
}

.modal-inline-form input[type="text"] {
  min-width: 220px;
}

.btn-modal-open {
  border: 0;
  cursor: pointer;
}

@media (max-width: 960px) {
  .admin-dialog,
  .admin-dialog.admin-dialog-wide {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .dialog-header {
    padding: 16px;
  }

  .dialog-subtitle {
    padding: 10px 16px 0;
  }

  .admin-dialog .form-grid,
  .admin-dialog .table-wrap,
  .admin-dialog .dialog-actions,
  .admin-dialog .dialog-inner-card {
    margin-left: 16px;
    margin-right: 16px;
  }

  .admin-dialog .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-inline-form {
    flex-wrap: wrap;
  }

  .modal-inline-form input[type="text"] {
    min-width: 0;
    width: 100%;
  }
}
