:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #6d6a64;
  --line: #d6d0c6;
  --paper: #f8f5ef;
  --panel: #fffdf8;
  --accent: #0f6b5f;
  --accent-dark: #094c44;
  --warn: #9f2d20;
  --shadow: rgba(24, 21, 17, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

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

button {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button.ghost,
.nav-item {
  background: transparent;
  color: var(--ink);
}

button.ghost:hover,
.nav-item:hover,
.nav-item.active {
  background: var(--ink);
  color: #fff;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  min-height: 460px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 6px;
}

label span,
.kicker,
.muted,
th,
.metrics span {
  color: var(--muted);
}

.kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.shell,
.login-view,
.app-view {
  min-height: 100vh;
}

.login-view {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 18px 50px var(--shadow);
  padding: 28px;
}

.app-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 24px;
}

.nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  text-align: left;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 8px 26px var(--shadow);
}

.metrics article {
  display: grid;
  gap: 8px;
  padding: 18px;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

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

.panel-head h3 {
  margin-bottom: 0;
}

.createUserForm,
.panel form,
#createUserForm {
  display: grid;
  gap: 13px;
}

.table-panel {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td code {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.message,
.error {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 13px;
}

.error {
  color: var(--warn);
}

.message {
  color: var(--accent);
}

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(21, 21, 21, 0.45);
}

.dialog-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

#tokenOutput {
  min-height: 120px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 960px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metrics,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
  }
}
