:root {
  --ink: #201c35;
  --muted: #6e6882;
  --paper: #f4f1f8;
  --panel: #fcfbfe;
  --line: #ded9e8;
  --purple: #5d3aa8;
  --purple-deep: #412776;
  --purple-wash: #eee8fb;
  --green: #247255;
  --green-wash: #e8f4ed;
  --red: #a13c54;
  --red-wash: #faeaee;
  --amber: #946218;
  --amber-wash: #fbf2df;
  --shadow: 0 18px 45px rgba(47, 31, 82, .08);
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.shell { max-width: 1260px; margin: 0 auto; padding: 24px 30px 48px; }
.masthead { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding: 8px 0 26px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { position: relative; width: 38px; height: 38px; border-radius: 11px; background: var(--purple); box-shadow: inset 0 -5px 0 rgba(25, 10, 64, .18); }
.brand-mark::before { content: ""; position: absolute; left: 12px; top: 9px; width: 0; height: 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-left: 15px solid #f5f0ff; }
.brand-name { font-size: 17px; letter-spacing: -.02em; font-weight: 760; }
.brand-sub { margin-top: 2px; color: var(--muted); font: 11px/1.2 ui-monospace, "Cascadia Code", monospace; letter-spacing: .08em; text-transform: uppercase; }
.operator-state { text-align: right; font-size: 13px; color: var(--muted); }
.operator-state strong { display: block; color: var(--ink); margin-bottom: 3px; }

.notice, .alert { margin: 18px 0; padding: 13px 15px; border: 1px solid; border-radius: 9px; font-size: 14px; line-height: 1.45; }
.notice { background: var(--purple-wash); border-color: #d9cef5; color: var(--purple-deep); }
.alert { background: var(--red-wash); border-color: #edc8d1; color: #7d243a; }
.hidden { display: none !important; }

.connect-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(290px, .82fr); gap: 18px; margin-top: 25px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.connect-card { padding: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--purple); font: 700 11px/1 ui-monospace, "Cascadia Code", monospace; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; max-width: 650px; font-size: clamp(28px, 4vw, 42px); line-height: 1.06; letter-spacing: -.045em; }
.lead { max-width: 650px; margin: 15px 0 26px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.field-label { display: block; margin-bottom: 8px; color: #49425b; font-size: 13px; font-weight: 700; }
.field-help { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.token-row { display: flex; gap: 10px; }
input { width: 100%; min-height: 43px; border: 1px solid #cfc8dc; border-radius: 7px; padding: 10px 12px; color: var(--ink); background: #fffefe; outline: none; }
input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(93, 58, 168, .14); }
.button { border: 1px solid transparent; border-radius: 7px; min-height: 42px; padding: 0 14px; color: #fff; background: var(--purple); font-weight: 720; font-size: 13px; white-space: nowrap; transition: transform .16s ease, background .16s ease; }
.button:hover:not(:disabled) { background: var(--purple-deep); transform: translateY(-1px); }
.button.secondary { color: var(--purple-deep); background: transparent; border-color: #bfb2dd; }
.button.secondary:hover:not(:disabled) { background: var(--purple-wash); }
.button.danger { background: var(--red); }
.button.danger:hover:not(:disabled) { background: #7e253c; }
.guide-card { padding: 24px; background: #ece7f4; box-shadow: none; }
.guide-card h2, .workspace-head h2, .form-card h2 { margin: 0; letter-spacing: -.025em; font-size: 18px; }
.guide-card ol { margin: 16px 0 0; padding-left: 19px; color: #504a60; font-size: 13px; line-height: 1.58; }
.guide-card code { color: var(--purple-deep); font-size: 12px; }
.guide-card p { color: var(--muted); font-size: 12px; line-height: 1.5; }

.workspace { margin-top: 25px; }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.workspace-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.console-grid { display: grid; grid-template-columns: minmax(270px, .7fr) minmax(0, 1.6fr); gap: 18px; align-items: start; }
.form-card { padding: 22px; }
.form-card h2 { margin-bottom: 18px; }
.form-card .field { margin-bottom: 15px; }
.field-inline { display: flex; justify-content: space-between; gap: 10px; }
.optional { color: var(--muted); font-size: 11px; font-weight: 500; }
.form-card .button { width: 100%; margin-top: 4px; }
.key-result { margin-top: 16px; padding: 14px; border: 1px solid #dbcdf6; border-radius: 8px; background: var(--purple-wash); }
.key-result p { margin: 0 0 8px; color: var(--purple-deep); font-size: 12px; line-height: 1.4; }
.key-value { display: block; overflow-wrap: anywhere; padding: 9px 10px; border-radius: 5px; color: #261548; background: #f9f6ff; font: 700 13px/1.35 ui-monospace, "Cascadia Code", monospace; }
.key-actions { display: flex; gap: 8px; margin-top: 10px; }
.key-actions .button { width: auto; min-height: 34px; margin: 0; }

.table-card { overflow: hidden; }
.table-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.table-meta h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.count { color: var(--muted); font: 12px ui-monospace, "Cascadia Code", monospace; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 690px; }
th { padding: 10px 18px; color: var(--muted); background: #f7f4fb; text-align: left; font: 700 10px/1.1 ui-monospace, "Cascadia Code", monospace; text-transform: uppercase; letter-spacing: .08em; }
td { padding: 14px 18px; border-top: 1px solid #ebe7f1; color: #403a4c; font-size: 13px; vertical-align: middle; }
td code { color: var(--ink); font: 12px ui-monospace, "Cascadia Code", monospace; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font: 700 10px/1 ui-monospace, "Cascadia Code", monospace; letter-spacing: .04em; text-transform: uppercase; }
.status.active, .status.issued { color: var(--green); background: var(--green-wash); }
.status.revoked, .status.expired { color: var(--red); background: var(--red-wash); }
.status.other { color: var(--amber); background: var(--amber-wash); }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }
.mini-button { min-height: 30px; padding: 0 9px; border: 1px solid #c9c0db; border-radius: 5px; color: var(--purple-deep); background: transparent; font-size: 11px; font-weight: 700; }
.mini-button:hover:not(:disabled) { background: var(--purple-wash); }
.mini-button.danger { border-color: #e2b4bf; color: var(--red); }
.mini-button.danger:hover:not(:disabled) { background: var(--red-wash); }
.empty { padding: 38px 20px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.5; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 13px 18px; border-top: 1px solid var(--line); }
.pagination span { color: var(--muted); font-size: 12px; }

.modal-backdrop { position: fixed; z-index: 5; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(33, 25, 52, .46); }
.modal { width: min(460px, 100%); padding: 25px; border: 1px solid #d8c8ee; border-radius: 12px; background: var(--panel); box-shadow: 0 28px 80px rgba(25, 14, 52, .25); }
.modal h2 { margin: 0 0 10px; font-size: 21px; letter-spacing: -.03em; }
.modal p { margin: 0; color: #5b546a; font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 23px; }

@media (max-width: 820px) {
  .shell { padding: 18px 16px 32px; }
  .masthead { padding-bottom: 18px; }
  .operator-state { display: none; }
  .connect-grid, .console-grid { grid-template-columns: 1fr; }
  .connect-card { padding: 23px 19px; }
}
@media (max-width: 520px) {
  .token-row { flex-direction: column; }
  .token-row .button { width: 100%; }
  .workspace-head { align-items: flex-start; flex-direction: column; }
  .workspace-head > .button { width: 100%; }
  .table-meta { align-items: flex-start; flex-direction: column; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
}