:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #172720;
  background: #f4f6f1;
  --ink: #172720;
  --muted: #58685e;
  --line: #dce4d9;
  --paper: #fff;
  --green: #185c44;
  --deep: #14382d;
  --mint: #c7edd8;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 2px solid #288260; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

.admin {
  --ink: #202722;
  --muted: #59625b;
  --line: #dde2dd;
  --paper: #fff;
  --green: #256848;
  --radius: 12px;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
  background: #f4f5f2;
  color: var(--ink);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: #fafbf9;
}
.brand { display: flex; gap: 10px; align-items: center; font-size: 15px; font-weight: 700; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: #c8efc4;
  color: #13372b;
  font-size: 19px;
  font-weight: 800;
}
.brand small { display: block; margin-top: 3px; color: #adc2b5; font-size: 11px; font-weight: 500; }
.sidebar .brand { gap: 8px; font-size: 16px; font-weight: 600; }
.sidebar .brand-mark { width: 32px; height: 32px; border-radius: 8px; background: #e0ebe3; color: var(--green); font-size: 16px; font-weight: 600; }
.sidebar .brand small { margin-top: 2px; color: var(--muted); font-weight: 400; }
.sidebar-label { margin: 24px 8px 0; color: var(--muted); font-size: 12px; }
.views { display: grid; gap: 4px; }
.views button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
}
.views button:hover, .canvas-link:hover { background: #eef0ed; color: var(--ink); }
.views button[aria-current] { border-color: #d7e3d9; background: #e8efe9; color: var(--green); font-weight: 600; }
.canvas-link { margin-top: 8px; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 12px; text-decoration: none; }
.canvas-link span { margin-left: 4px; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 4px 0; color: var(--muted); font-size: 11px; }
.environment-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--green); vertical-align: 1px; }

.workspace { max-width: 1560px; width: 100%; margin: 0 auto; padding: 28px 32px 24px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 700; }
h1 { margin: 7px 0; font-size: clamp(27px, 3.2vw, 36px); letter-spacing: -.04em; line-height: 1.2; }
.page-header .eyebrow { color: var(--muted); font-weight: 500; }
.page-header h1 { margin: 4px 0; font-size: clamp(26px, 3.2vw, 34px); font-weight: 600; letter-spacing: -.02em; }
.page-header p, .records-heading p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.environment-badge { color: var(--muted); font-size: 12px; white-space: nowrap; }
.button { min-height: 36px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 12px; white-space: nowrap; }
.button:hover { background: #eef0ed; }
.load-status { min-height: 16px; margin: 8px 0 12px; color: var(--muted); font-size: 12px; }
.load-status[data-error], .filter-error { color: #9f3228; }

.metrics { display: grid; grid-template-columns: minmax(0, 2fr) minmax(224px, 1fr); gap: 12px; }
.wallet-overview, .ledger-summary { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.wallet-overview { padding: 16px 20px; }
.wallet-values { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin: 8px 0; }
.wallet-values > div:last-child { text-align: right; }
.wallet-values dt, .channel-card dt { color: var(--muted); font-size: 12px; }
.wallet-amount {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
#available { color: var(--green); }
#reserved { font-size: clamp(20px, 2.5vw, 28px); }
.wallet-meter { display: block; width: 100%; height: 8px; margin-top: 12px; appearance: none; background: #e2e6e0; border: 0; border-radius: 4px; }
.wallet-meter::-webkit-meter-bar { height: 8px; background: #e2e6e0; border: 0; border-radius: 4px; }
.wallet-meter::-webkit-meter-optimum-value { background: var(--green); border-radius: 4px; }
.wallet-meter::-moz-meter-bar { background: var(--green); border-radius: 4px; }
.ledger-summary { padding: 0 16px; }
.ledger-summary dl { display: grid; grid-template-rows: 1fr 1fr; height: 100%; margin: 0; }
.ledger-summary dl > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; }
.ledger-summary dl > div + div { border-top: 1px solid var(--line); }
.ledger-summary dt { font-size: 13px; font-weight: 500; }
.ledger-summary dt small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.ledger-summary dd { margin: 0; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }

.channel-section { margin-top: 20px; }
.section-heading, .records-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.admin h2 { font-size: 16px; font-weight: 600; }
.wallet-overview h2 { font-size: 14px; }
.section-heading > span, .muted { color: var(--muted); font-size: 12px; }
.channels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.channel-card { min-width: 0; padding: 12px 16px; }
.channel-card + .channel-card { border-left: 1px solid var(--line); }
.channel-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.channel-card h3 { font-size: 14px; font-weight: 600; }
.channel-mode { color: var(--muted); font-size: 11px; white-space: nowrap; }
.channel-card dl { display: grid; grid-template-columns: 1fr 1fr 1fr 2fr; gap: 8px; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); }
.channel-card dd { margin: 4px 0 0; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.records { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.records-heading { padding: 16px 16px 4px; }
.records-heading p { margin-top: 4px; }
.match-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) auto; align-items: end; gap: 8px; padding: 8px 16px 16px; }
.filters label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 12px; }
.filters input, .filters select {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  color: var(--ink);
  background: #fafbf9;
  font-size: 12px;
}
.filters input::placeholder { color: #69756b; }
.filters .button { justify-self: start; }
.filter-error { padding: 0 16px 12px; font-size: 12px; }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: -3px; }
table { width: 100%; min-width: 640px; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 8px 12px; border-top: 1px solid #e6e9e5; vertical-align: top; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
th { color: var(--muted); background: #f4f6f3; font-size: 12px; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #f8faf7; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.numeric .value-main, .unbroken .value-main { white-space: nowrap; }
.value-main, .value-sub { display: block; overflow-wrap: anywhere; }
.value-sub { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.pill { display: inline-block; border-radius: 4px; padding: 2px 4px; background: #eff1ee; color: #48514a; font-size: 11px; white-space: nowrap; }
.pill.pending { background: #fbefd8; color: #74480b; }
.pill.problem { background: #f7e4e0; color: #8b3828; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.main-footer { display: flex; gap: 12px; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 11px; }

.canvas { min-height: 100vh; background: #eaf0e9; }
.canvas-header { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 24px; border-bottom: 1px solid #d1ded2; background: #fbfdfa; }
.canvas-balance { display: flex; gap: 9px; align-items: baseline; padding: 7px 10px; border: 1px solid #cfded0; border-radius: 8px; background: #e8f2e7; color: var(--deep); font-size: 12px; white-space: nowrap; }
.canvas-balance strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.canvas-space { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 24px; background-image: radial-gradient(#b5c8ba 1px, transparent 1px); background-size: 20px 20px; }
.canvas-node { max-width: 380px; width: 100%; padding: 23px; border: 1px solid #b9cdbd; border-radius: var(--radius); background: #fbfdfa; box-shadow: 0 8px 22px #24443213; }
.node-icon { display: grid; width: 38px; height: 38px; place-items: center; margin-bottom: 13px; border-radius: 9px; background: #dff0e2; }
.node-icon svg { width: 23px; stroke: var(--green); stroke-width: 1.55; }
.canvas-node h1 { margin: 7px 0; font-size: 26px; }
.canvas-node p { color: var(--muted); font-size: 13px; line-height: 1.75; }
.canvas-node .filter-error { padding: 7px 0 0; color: #9f3228; }

.sidebar-footer:has(.text-button:not([hidden])) { display: grid; gap: 12px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--green); font-size: 12px; text-align: left; }
.text-button:hover { text-decoration: underline; }
.readiness-notice { margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf9; color: var(--muted); font-size: 13px; line-height: 1.6; }

.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: #f4f5f2; }
.auth-panel { width: min(100%, 400px); padding: 28px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.auth-panel h1 { margin: 20px 0 8px; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.auth-panel > p, .issued-token p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.admin-form { display: grid; gap: 12px; margin-top: 16px; }
.admin-form > label, .issue-fields > label { display: grid; min-width: 0; gap: 4px; color: var(--muted); font-size: 13px; }
.admin-form label > input:not([type="checkbox"]), .admin-form select, .token-actions input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbf9;
  color: var(--ink);
  font-size: 14px;
}
.auth-panel .primary-button { min-height: 40px; font-size: 14px; }
.primary-button, .primary-button:hover { border-color: var(--green); background: var(--green); color: #fff; }
.primary-button:hover { background: #174a34; }
.form-message { color: var(--muted); font-size: 13px; line-height: 1.6; }
.form-message:empty { display: none; }
.form-message[data-error] { color: #9f3228; }

.sidebar-item { display: block; min-height: 36px; padding: 8px 12px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); font-size: 13px; text-decoration: none; }
.sidebar-item:hover { background: #eef0ed; color: var(--ink); }
.sidebar-item[aria-current] { border-color: #d7e3d9; background: #e8efe9; color: var(--green); font-weight: 600; }
.connection-state, .integration-card { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.readiness-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 12px 0 0; }
.readiness-list dt { color: var(--muted); font-size: 12px; }
.readiness-list dd { margin: 4px 0 0; font-size: 14px; font-weight: 600; }
.integration-card { margin-top: 20px; }
#wallet-requirement { margin-top: 8px; }
.issue-form { justify-items: start; }
.issue-fields { display: grid; width: 100%; grid-template-columns: 1fr 1fr minmax(120px, .35fr); gap: 12px; }
.scope-options { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0; border: 0; }
.scope-options legend { padding: 0; color: var(--muted); font-size: 13px; }
.scope-options label { display: flex; min-height: 28px; align-items: center; gap: 4px; font-size: 13px; }
.scope-options input { accent-color: var(--green); }
.issued-token { margin-top: 16px; padding: 12px; border: 1px solid #d7e3d9; border-radius: 8px; background: #f4f7f4; }
.issued-token h3 { margin-bottom: 4px; font-size: 15px; font-weight: 600; }
.token-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin-top: 8px; }
.token-actions input { font-family: ui-monospace, monospace; }
.issued-token .form-message:not(:empty) { margin-top: 4px; }
.integrations .records-heading { padding-bottom: 16px; }
.integrations td:first-child, .integrations td:nth-child(2) { overflow-wrap: anywhere; }
.integrations .date-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 850px) {
  .admin { grid-template-columns: 148px minmax(0, 1fr); }
  .sidebar { padding-right: 12px; padding-left: 12px; }
  .workspace { padding: 24px 20px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: minmax(0, 1fr); }
  .channel-card dl { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .admin { display: block; }
  .sidebar { position: static; height: auto; gap: 8px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-label, .sidebar-footer { display: none; }
  .views { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .views button { padding: 8px 4px; font-size: 12px; text-align: center; }
  .canvas-link { align-self: flex-start; margin: 0; padding: 4px 0; }
  .workspace { padding: 16px; }
  .wallet-overview, .channel-card { padding: 12px; }
  .ledger-summary { padding: 0 12px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .canvas-header { padding: 10px 13px; }
  .integrations { padding: 16px; }
  .admin:has(.integrations) .views { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .issue-fields { grid-template-columns: minmax(0, 1fr); }
  .sidebar-footer:has(.text-button:not([hidden])) { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }
}
