:root {
  color-scheme: light;
  --paper: #f8f3e8;
  --surface: #fffdf7;
  --surface-2: #f0ece1;
  --ink: #18201d;
  --muted: #697069;
  --line: #d8d1c2;
  --green: #24382d;
  --green-2: #33533e;
  --amber: #c89538;
  --blue: #2f5f82;
  --red: #8e332e;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100svh;
  margin: 0;
  background: linear-gradient(135deg, #f7f2e7 0%, #ece6d9 52%, #e5ebea 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: #fffdf7;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

button.danger {
  background: var(--red);
}

button.subtle {
  border: 1px solid rgba(142, 51, 46, 0.24);
  background: rgba(142, 51, 46, 0.08);
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(36, 56, 45, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.hidden {
  display: none !important;
}

.login-view {
  width: min(100%, 470px);
  margin: min(12svh, 90px) auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0)), var(--paper);
  box-shadow: 0 24px 70px rgba(47, 39, 27, 0.12);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
}

.brand-mark svg {
  width: 29px;
  height: 29px;
  stroke-width: 1.8;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.login-view h1,
.topbar h1 {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-weight: 500;
  letter-spacing: 0;
}

.login-view h1 {
  margin-bottom: 28px;
  font-size: clamp(42px, 9vw, 58px);
  line-height: 0.98;
}

.login-form,
.stack-form {
  display: grid;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1 {
  margin-top: 2px;
  font-size: clamp(38px, 6vw, 62px);
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
}

.status {
  min-height: 22px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.status.error {
  color: var(--red);
}

.status.ok {
  color: var(--green-2);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metrics div {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px 16px;
  background: rgba(255, 253, 247, 0.72);
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metrics strong {
  font-size: 24px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.7);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
}

.panel-head.compact {
  padding: 0 0 10px;
}

h2,
h3 {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 16px;
  font-weight: 650;
}

.row-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 96px;
  gap: 10px;
  padding: 0 16px 16px;
}

.key-panel .stack-form {
  padding: 0 16px 16px;
}

.user-detail {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid rgba(216, 209, 194, 0.74);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.36);
}

.user-detail h3 {
  margin-top: 4px;
  font-size: 22px;
}

.user-detail .muted {
  overflow-wrap: anywhere;
}

.keys-list-section {
  padding: 0 16px 16px;
}

.contacts-section {
  padding: 0 16px 16px;
}

.contact-form {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) 76px;
  gap: 10px;
  margin-bottom: 10px;
}

.keys-table,
.contacts-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.36);
}

.key-row,
.contact-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid rgba(216, 209, 194, 0.7);
}

.contact-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.key-row:last-child,
.contact-row:last-child {
  border-bottom: 0;
}

.key-row strong,
.contact-row strong {
  display: block;
  font-size: 14px;
}

.key-row > div,
.contact-row > div {
  min-width: 0;
}

.key-row span,
.contact-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.key-row.is-revoked {
  opacity: 0.62;
}

.status-pill {
  min-width: 68px;
  margin-top: 0 !important;
  padding: 5px 9px;
  border-radius: 999px;
  text-align: center;
  font-size: 11px !important;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill.is-active {
  background: rgba(51, 83, 62, 0.1);
  color: var(--green-2);
}

.status-pill.is-revoked {
  background: rgba(105, 112, 105, 0.12);
  color: var(--muted);
}

.section-divider {
  height: 1px;
  margin: 0 16px 16px;
  background: var(--line);
}

.mint-head {
  padding: 0 16px 12px;
}

.list {
  display: grid;
  border-top: 1px solid var(--line);
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(216, 209, 194, 0.7);
  border-left: 3px solid transparent;
  border-right: 0;
  border-top: 0;
  border-radius: 0;
  text-align: left;
}

.user-row:last-child {
  border-bottom: 0;
}

.user-row.is-selected {
  background: rgba(36, 56, 45, 0.08);
  border-left-color: var(--green);
}

.user-row strong {
  display: block;
  font-size: 15px;
}

.user-row span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.quota {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.key-result {
  margin: 0 16px;
  padding: 12px;
  border: 1px solid rgba(200, 149, 56, 0.42);
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.8);
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-head h3 {
  margin-bottom: 4px;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.key-result textarea {
  min-height: 120px;
  margin-top: 12px;
  background: rgba(255, 253, 247, 0.76);
}

.key-result.is-collapsed textarea {
  display: none;
}

.calls-panel {
  margin-top: 16px;
}

.calls-panel select {
  max-width: 260px;
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

.calls-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
  border-top: 1px solid var(--line);
}

.calls-layout .table-wrap {
  border-top: 0;
  border-right: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(216, 209, 194, 0.7);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

tbody tr {
  cursor: pointer;
  transition: background 140ms ease;
}

tbody tr:hover,
tbody tr:focus-visible {
  background: rgba(36, 56, 45, 0.06);
  outline: none;
}

tbody tr.is-selected {
  background: rgba(36, 56, 45, 0.1);
}

tbody tr.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--green);
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td code {
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.empty {
  padding: 18px 16px;
  color: var(--muted);
  font-size: 14px;
}

.call-detail {
  min-height: 420px;
  max-height: 720px;
  overflow: auto;
  padding: 16px;
  background: rgba(255, 253, 247, 0.42);
}

.call-detail h3 {
  margin: 4px 0 14px;
  overflow-wrap: anywhere;
  font-size: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.detail-grid div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  background: rgba(255, 253, 247, 0.72);
}

.detail-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.detail-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(216, 209, 194, 0.78);
}

.detail-block h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-block pre {
  overflow-x: auto;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.error-text pre {
  color: var(--red);
}

.transcript-block {
  display: grid;
  gap: 10px;
}

.transcript-line {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(216, 209, 194, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.34);
}

.transcript-line strong {
  color: var(--blue);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.transcript-line p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 12px 0;
  }

  .workspace,
  .metrics,
  .calls-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .calls-layout .table-wrap {
    border-right: 0;
  }

  .call-detail {
    max-height: none;
    border-top: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .row-form,
  .contact-form,
  .user-detail,
  .contact-row,
  .key-row {
    width: 100%;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .result-head,
  .result-actions {
    width: 100%;
  }

  .result-head {
    flex-direction: column;
  }

  .result-actions button {
    flex: 1;
  }

  .topbar-actions button {
    flex: 1;
  }

  .login-view {
    margin-top: 34px;
    padding: 24px;
  }
}
