:root {
  --bg: #f5f7fa; --card: #fff; --border: #e5e9f0; --text: #0d1426; --dim: #6b7488;
  --primary: #2f6bff; --primary-hover: #245be6; --danger: #c92d2d;
  --ok: #1e8b3a; --warn: #b8790a; --shadow: 0 2px 8px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Login */
.login { max-width: 400px; margin: 100px auto; background: #fff; padding: 30px; border-radius: 12px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 12px; }
.login input, input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }
.login button, button { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 14px; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 500; }
button.primary:hover { background: var(--primary-hover); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: var(--danger); }
.err { color: var(--danger); }

/* Layout */
header { display: flex; align-items: center; gap: 20px; background: #0d1426; color: #fff; padding: 10px 20px; }
header .brand { font-weight: 700; font-size: 16px; }
header nav { display: flex; gap: 4px; flex: 1; }
header nav button { background: transparent; color: #fff; border: 0; padding: 6px 14px; border-radius: 6px; opacity: .7; }
header nav button:hover { opacity: 1; background: rgba(255,255,255,.08); }
header nav button.active { opacity: 1; background: rgba(255,255,255,.15); }
header .who { display: flex; align-items: center; gap: 10px; }
header .who .dim { color: #94a2b8; font-size: 12px; }
header .who button { background: transparent; color: #fff; border: 1px solid #2c3650; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

/* Cards & tables */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { color: var(--dim); font-size: 12px; }
.tile .value { font-size: 24px; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
thead th { background: #fafbfd; padding: 10px 12px; text-align: left; font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--border); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.dim { color: var(--dim); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.pill-received  { background: #eef; color: #446; }
.pill-uploaded  { background: #ffeec2; color: #7a6500; }
.pill-signing   { background: #dceafd; color: #245be6; }
.pill-signed    { background: #d4f5db; color: #1e8b3a; }
.pill-failed    { background: #ffd6d6; color: #c92d2d; }
.pill-cancelled { background: #eee; color: #666; }
.pill-active    { background: #d4f5db; color: #1e8b3a; }
.pill-disabled  { background: #eee; color: #666; }
.pill-paired    { background: #eef; color: #446; }
.pill-offline   { background: #ffd6d6; color: #c92d2d; }
.pill-unpaired  { background: #ffeec2; color: #7a6500; }
.pill-cert_expired { background: #ffd6d6; color: #c92d2d; }
.pill-queued    { background: #eef; color: #446; }
.pill-leased    { background: #ffeec2; color: #7a6500; }
.pill-done      { background: #d4f5db; color: #1e8b3a; }

.row { display: flex; gap: 12px; align-items: center; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.actions { display: flex; gap: 6px; }
code { font-family: 'JetBrains Mono', ui-monospace, monospace; background: #f0f2f5; padding: 2px 6px; border-radius: 4px; font-size: 12px; word-break: break-all; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 20px; max-width: 600px; width: 90%; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .time { color: var(--dim); font-size: 11px; }
