/* public/assets/app.css
   后台静态页面共享样式。简洁、克制、无第三方依赖。
*/

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e3e5e8;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #15803d;
  --warn: #92400e;
  --row-hover: #f3f4f6;
  --code-bg: #f6f8fa;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 12px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'PingFang SC', 'Hiragino Sans GB', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.danger-text { color: var(--danger); }

code { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg); padding: 1px 4px; border-radius: 3px; }

/* ---- topbar ---- */
#topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { font-weight: 600; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { padding: 6px 12px; border-radius: 6px; color: var(--text); }
.tab:hover { background: var(--row-hover); text-decoration: none; }
.tab.active { background: var(--accent); color: #fff; }
.tab.active:hover { background: var(--accent-hover); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ---- main ---- */
main { max-width: 1200px; margin: 0 auto; padding: 24px; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 12px; }
h3 { font-size: 14px; margin: 12px 0 8px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---- form ---- */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--row-hover); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}
textarea { resize: vertical; min-height: 60px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.field { margin-bottom: 12px; }
.field-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; color: var(--text); font-size: 14px; }

/* ---- table ---- */
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: var(--row-hover); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }
td.mono { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }

/* ---- badge ---- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  background: var(--row-hover);
  color: var(--text);
}
.badge.active, .badge.success { background: #dcfce7; color: var(--success); }
.badge.banned, .badge.revoked, .badge.expired,
.badge.canceled, .badge.failure, .badge.denied,
.badge.replay_detected, .badge.invalid_signature, .badge.invalid_session {
  background: #fee2e2; color: var(--danger-hover);
}
.badge.handshake, .badge.login, .badge.activate, .badge.heartbeat,
.badge.license_status, .badge.refresh, .badge.deactivate {
  background: #dbeafe; color: #1e40af;
}
.badge.warn, .badge.inactive { background: #fef3c7; color: var(--warn); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e5e7eb;
  color: var(--text);
  font-size: 11px;
  margin: 1px 2px 1px 0;
}

/* ---- flash ---- */
.flash {
  position: fixed;
  top: 12px;
  right: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 360px;
}
.flash.error { background: #fee2e2; color: var(--danger-hover); }
.flash.info { background: #dbeafe; color: #1e40af; }

/* ---- modal ---- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
  width: 480px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.modal h3 { margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ---- dashboard ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 700px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: block;
  color: var(--text);
}
.card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0, 0, 0, .08); }
.card h2 { margin: 0 0 6px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---- json ---- */
pre.json {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- detail kv ---- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---- login ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  width: 360px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 20px; text-align: center; font-size: 20px; }

/* ---- pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.pagination .muted { font-size: 12px; }

/* ---- empty state ---- */
.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---- expanded audit row ---- */
tr.audit-detail-row td {
  background: var(--code-bg);
  padding: 8px 16px;
}
