:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #192d40;
  background: #f4f6f8;
  font-size: 14px;
  --nav: #112234;
  --ink: #192d40;
  --muted: #6a7887;
  --line: #e1e7ec;
  --blue: #315bdc;
  --green: #147d64;
  --amber: #b26b1c;
  --red: #b83f47;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f4f6f8; color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); border-radius: 7px; background: white; padding: 10px 16px; color: var(--ink); font-weight: 600; transition: all .15s ease; }
button:hover { background: #eef2f6; }
button.primary { background: var(--blue); border-color: var(--blue); color: white; }
button.primary:hover { background: #254bc0; }
button.success { background: var(--green); border-color: var(--green); color: white; }
button.success:hover { background: #0f624e; }
button.danger { background: #fff5f5; border-color: #f2d2d4; color: var(--red); }
button.danger:hover { background: #fee8e9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; position: fixed; inset: 0 auto 0 0; background: var(--nav); color: #fff; padding: 28px 20px; display: flex; flex-direction: column; z-index: 10; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 4px; margin-bottom: 30px; font-weight: 600; font-size: 17px; }
.brand-mark { width: 34px; height: 38px; background: #628cf8; clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); display: grid; place-items: center; color: #112234; font-size: 20px; font-weight: 900; }
.brand em { font-style: normal; color: #8ca0b3; font-size: 10px; letter-spacing: 2px; display: block; margin-top: 3px; }

.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #6f879c; padding: 0 12px; margin: 18px 0 8px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav button { border: 0; text-align: left; display: flex; align-items: center; gap: 12px; background: none; color: #a7b8c9; padding: 11px 12px; font-size: 13px; font-weight: 500; border-radius: 6px; }
.sidebar nav button:hover { background: #1a3149; color: #fff; }
.sidebar nav button.selected { background: #223e5c; color: #fff; font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-bottom { margin-top: auto; padding-top: 20px; border-top: 1px solid #243a50; font-size: 11px; color: #8ca0b3; line-height: 1.7; }
.sidebar-bottom strong { color: #dbe5ee; display: block; margin-bottom: 4px; font-size: 12px; }

.main { margin-left: 260px; width: calc(100% - 260px); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 68px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 40px; }
.breadcrumb { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.breadcrumb b { color: var(--ink); }
.top-actions { display: flex; gap: 12px; align-items: center; }

.content { padding: 36px 40px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }
.heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 20px; }
.heading h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.5px; }
.heading p { margin: 0; color: var(--muted); font-size: 13px; }

.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; color: var(--blue); margin-bottom: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 5px; background: #edf1f5; color: #596d7e; padding: 4px 9px; font-size: 11px; font-weight: 700; }
.badge.green { color: #147d64; background: #e5f5ee; }
.badge.blue { color: #315bdc; background: #edf2fc; }
.badge.amber { color: #b26b1c; background: #fdf5e7; }
.badge.red { color: #b83f47; background: #fcebed; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.hero { background: linear-gradient(135deg, #eef3ff 0%, #e5edfc 100%); border: 1px solid #d4e0f9; border-radius: 12px; padding: 26px 30px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.hero h2 { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: #1c3560; }
.hero p { margin: 0; font-size: 13px; color: #4e678a; max-width: 680px; line-height: 1.6; }

.grid { display: grid; gap: 22px; }
.metrics { grid-template-columns: repeat(4, 1fr); margin-bottom: 26px; }
.metric { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.metric-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px; }
.metric-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.metric small { font-size: 11px; color: var(--muted); }

.card { background: white; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.card-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.card-body { padding: 24px; }

table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th { background: #f8fafc; color: #627282; padding: 12px 18px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--line); }
td { padding: 14px 18px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; }
.raw-val { color: #b83f47; font-weight: 600; background: #fff0f1; padding: 2px 6px; border-radius: 4px; }
.token-val { color: #147d64; font-weight: 600; background: #e5f5ee; padding: 2px 6px; border-radius: 4px; }
.redact-val { color: #8e6224; font-style: italic; background: #fef7ec; padding: 2px 6px; border-radius: 4px; }

.code-box { background: #112234; color: #cbe0f5; padding: 18px 20px; border-radius: 8px; font-family: ui-monospace, monospace; font-size: 11px; line-height: 1.7; overflow-x: auto; max-height: 380px; }
.diff-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 14px; }

.notice { background: #f7f9fc; border: 1px solid #dce5ef; border-radius: 8px; padding: 16px 20px; font-size: 12px; line-height: 1.65; color: #435b73; margin: 16px 0; }
.notice.success { background: #e8f7f1; border-color: #c0ebd8; color: #115743; }
.notice.warning { background: #fff8eb; border-color: #fae4be; color: #835613; }
.notice.danger { background: #fdf0f1; border-color: #f7ced2; color: #8c262d; }

.proof-pill { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; font-size: 12px; }

#toast { position: fixed; right: 28px; bottom: 28px; background: #112234; color: white; padding: 16px 22px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.18); font-size: 13px; z-index: 100; display: none; }
#toast.show { display: block; animation: fadeIn .2s; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Token Modal & RBAC Styling */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 34, 52, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn .15s ease-out;
}
.modal-card {
  background: white;
  border-radius: 12px;
  max-width: 680px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  overflow: hidden;
  border: 1px solid var(--line);
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.modal-close:hover { color: var(--ink); background: none; }
.modal-body { padding: 24px; max-height: calc(85vh - 80px); overflow-y: auto; }
.role-grid { display: grid; gap: 14px; margin: 18px 0; }
.role-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fdfdfd;
  transition: all .15s ease;
}
.role-card:hover { border-color: #b5c7da; background: #fff; }
.role-card.active {
  border-color: var(--blue);
  background: #f7faff;
  box-shadow: 0 0 0 1px var(--blue);
}
.role-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.role-desc { font-size: 12px; color: var(--muted); margin: 8px 0 12px; line-height: 1.5; }
.token-copy-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #edf2f7;
  padding: 6px 12px;
  border-radius: 6px;
  gap: 10px;
}
.token-preview { font-size: 11px; color: #2c4257; word-break: break-all; }
.btn-copy-token {
  font-size: 11px;
  padding: 4px 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.btn-copy-token:hover { background: #eef2f6; }
.btn-activate-role { font-size: 11px; padding: 6px 12px; }
.manual-token-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}

/* Auth Gate Lock Screen */
.auth-gate {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, #1e3650 0%, #112234 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn .2s ease-out;
}
.auth-card {
  background: white;
  border-radius: 14px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
  padding: 36px 32px;
  border: 1px solid rgba(255,255,255,0.1);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.auth-brand h2 { margin: 0; font-size: 20px; color: var(--ink); }
.auth-brand em { font-style: normal; color: var(--muted); font-size: 10px; letter-spacing: 1.5px; display: block; }
.auth-notice {
  background: #f4f7fb;
  border: 1px solid #dce5ef;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 22px;
}
.auth-notice h3 { margin: 0 0 6px; font-size: 14px; color: #1c3560; }
.auth-notice p { margin: 0; font-size: 12px; color: #4e678a; line-height: 1.5; }
.auth-footer { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 11px; text-align: center; }
