:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --ink: #17201a;
  --muted: #68736c;
  --line: #dce2dd;
  --line-strong: #c9d1cb;
  --sidebar: #19221c;
  --sidebar-soft: #243029;
  --green: #18794e;
  --green-dark: #0f5f3b;
  --green-soft: #e8f5ed;
  --teal: #167483;
  --teal-soft: #e5f3f5;
  --amber: #a96408;
  --amber-soft: #fff3d9;
  --red: #b3423d;
  --red-soft: #fbeceb;
  --violet: #6f5a9c;
  --shadow: 0 16px 48px rgba(23, 32, 26, 0.14);
  --sidebar-width: 224px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: var(--sidebar);
  color: #edf3ee;
  border-right: 1px solid #2e3b33;
}

.brand {
  display: flex;
  height: 78px;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-bottom: 1px solid #2c3931;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #5a7765;
  border-radius: 6px;
  color: #b9f0ce;
  background: #24372b;
  font-size: 13px;
  font-weight: 800;
}

.brand-name {
  display: flex;
  flex-direction: column;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.1;
}

.brand-name small {
  margin-top: 4px;
  color: #87998c;
  font-size: 9px;
  font-weight: 650;
}

.primary-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 18px 10px;
}

.nav-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 6px;
  color: #aab8ae;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease;
}

.nav-link:hover {
  color: #ffffff;
  background: #222f27;
}

.nav-link.active {
  color: #d9f7e4;
  background: #2b3b31;
  box-shadow: inset 3px 0 0 #57b77d;
}

.sidebar-footer {
  padding: 14px 12px 18px;
  border-top: 1px solid #2c3931;
}

.service-state {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 7px;
  color: #9eada2;
  font-size: 12px;
}

.state-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a96408;
  box-shadow: 0 0 0 3px rgba(169, 100, 8, 0.18);
}

.state-dot.online,
.state-dot.ready {
  background: #43a66a;
  box-shadow: 0 0 0 3px rgba(67, 166, 106, 0.18);
}

.key-control {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  color: #c7d3ca;
  background: transparent;
  cursor: pointer;
}

.key-control:hover {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.main-content {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 0 32px 48px;
}

.page-header {
  display: flex;
  min-height: 104px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-leading,
.header-actions,
.header-actions > * {
  min-width: 0;
}

.header-leading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header h1 {
  margin: 3px 0 0;
  font-size: 25px;
  line-height: 1.2;
  font-weight: 760;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  font-weight: 750;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.updated-at {
  margin-right: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.btn,
.icon-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.btn {
  min-height: 38px;
  gap: 8px;
  padding: 0 14px;
  font-weight: 650;
}

.btn.primary {
  color: #ffffff;
  border-color: var(--green);
  background: var(--green);
}

.btn.primary:hover {
  border-color: var(--green-dark);
  background: var(--green-dark);
}

.btn.secondary {
  color: #354039;
  border-color: var(--line-strong);
  background: var(--surface);
}

.btn.secondary:hover {
  border-color: #9fac9f;
  background: var(--surface-soft);
}

.btn.danger {
  color: #ffffff;
  border-color: var(--red);
  background: var(--red);
}

.btn:disabled,
.icon-btn:disabled,
.segmented button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #59655d;
  border-color: transparent;
  background: transparent;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line);
  background: #f3f6f3;
}

[data-tooltip]::after {
  position: absolute;
  z-index: 200;
  bottom: calc(100% + 7px);
  left: 50%;
  max-width: 180px;
  padding: 5px 7px;
  transform: translate(-50%, 3px);
  border-radius: 4px;
  color: #ffffff;
  background: #202722;
  content: attr(data-tooltip);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease, transform 100ms ease;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-menu {
  display: none;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 116px;
  margin: 0 -32px;
  padding: 0 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.metric-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 18px 24px;
  border-right: 1px solid var(--line);
}

.metric-item:first-child {
  padding-left: 0;
}

.metric-item:last-child {
  border-right: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.metric-item strong {
  margin-top: 6px;
  font-size: 27px;
  line-height: 1.05;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.metric-note {
  min-height: 18px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.quota-distribution {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) repeat(4, minmax(110px, 1fr));
  min-height: 76px;
  margin: 0 -32px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.quota-distribution-heading,
.quota-bucket {
  display: flex;
  min-width: 0;
  justify-content: center;
  padding: 14px 24px;
  border-right: 1px solid var(--line);
}

.quota-distribution-heading {
  flex-direction: column;
  padding-left: 0;
}

.quota-distribution-heading strong {
  font-size: 13px;
  line-height: 1.25;
}

.quota-distribution-heading span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.quota-bucket {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quota-bucket:last-child {
  border-right: 0;
}

.quota-bucket > span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quota-bucket > div {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 4px;
}

.quota-bucket strong {
  font-size: 23px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.quota-bucket small {
  color: var(--muted);
  font-size: 10px;
}

.view-tabs {
  display: flex;
  height: 62px;
  align-items: end;
  gap: 26px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  position: relative;
  height: 44px;
  padding: 0 2px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
  cursor: pointer;
}

.view-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
}

.view-tab.active {
  color: var(--ink);
}

.view-tab.active::after {
  background: var(--green);
}

.view-panel {
  display: none;
  min-width: 0;
}

.view-panel.active {
  display: block;
}

.table-toolbar {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 10px;
}

.search-field,
.job-lookup {
  display: flex;
  min-width: 220px;
  height: 36px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.search-field:focus-within,
.job-lookup:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 121, 78, 0.1);
}

.search-field input,
.job-lookup input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-field input::placeholder,
.job-lookup input::placeholder,
textarea::placeholder {
  color: #98a19b;
}

.select-control,
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  outline: 0;
  background: var(--surface);
}

.reference-image-field {
  grid-column: 1 / -1;
}

.reference-image-field small {
  float: right;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.reference-picker-button {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.reference-picker-button:hover { border-color: var(--green); background: var(--surface-soft); }
.reference-picker-button span { flex: 1; text-align: left; }
.reference-picker-button svg:last-child { color: var(--muted); }

.reference-file-modal form { width: min(780px, calc(100vw - 32px)); }

.reference-file-grid {
  display: grid;
  max-height: min(560px, 66vh);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
}

.reference-file-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.reference-file-item.selected { border-color: var(--green); box-shadow: 0 0 0 2px rgba(24, 121, 78, 0.12); }
.reference-file-item > span:last-child { min-width: 0; }
.reference-file-item strong,
.reference-file-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-file-item strong { font-size: 11px; }
.reference-file-item small { margin-top: 3px; color: var(--muted); font-size: 9px; }

.reference-file-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  background: #e9ede9;
}

.reference-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.reference-file-thumb svg { position: absolute; top: 6px; right: 6px; color: transparent; fill: transparent; }
.reference-file-item.selected .reference-file-thumb svg { color: #ffffff; fill: var(--green); }

.select-control {
  width: auto;
  min-width: 130px;
  height: 36px;
  padding: 0 30px 0 10px;
}

.select-control:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 121, 78, 0.1);
}

.row-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.table-wrap {
  position: relative;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th {
  height: 42px;
  padding: 0 14px;
  color: #6c766f;
  background: #f6f8f5;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  height: 66px;
  padding: 10px 14px;
  border-bottom: 1px solid #e9ede9;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  transition: background 100ms ease;
}

.data-table tbody tr:hover {
  background: #f9fbf9;
}

.account-table th:nth-child(1) { width: 25%; }
.account-table th:nth-child(2) { width: 10%; }
.account-table th:nth-child(3) { width: 18%; }
.account-table th:nth-child(4) { width: 11%; }
.account-table th:nth-child(5) { width: 12%; }
.account-table th:nth-child(6) { width: 13%; }
.account-table th:nth-child(7) { width: 116px; }

.jobs-table th:nth-child(1) { width: 29%; }
.jobs-table th:nth-child(2) { width: 15%; }
.jobs-table th:nth-child(3) { width: 15%; }
.jobs-table th:nth-child(4) { width: 11%; }
.jobs-table th:nth-child(5) { width: 12%; }
.jobs-table th:nth-child(6) { width: 14%; }
.jobs-table th:nth-child(7) { width: 44px; }

.login-table th:nth-child(1) { width: 22%; }
.login-table th:nth-child(2) { width: 9%; }
.login-table th:nth-child(3) { width: 9%; }
.login-table th:nth-child(4) { width: 18%; }
.login-table th:nth-child(5) { width: 27%; }
.login-table th:nth-child(6) { width: 15%; }

.account-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.account-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 750;
}

.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-copy,
.job-copy,
.model-copy {
  min-width: 0;
}

.account-copy strong,
.job-copy strong,
.model-copy strong {
  display: block;
  overflow: hidden;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy span,
.job-copy span,
.model-copy span,
.cell-muted {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge,
.type-badge,
.method-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.active,
.status-badge.succeeded {
  color: var(--green-dark);
  border-color: #bfe1cc;
  background: var(--green-soft);
}

.status-badge.disabled,
.status-badge.canceled {
  color: #59625c;
  border-color: #d9dedb;
  background: #f0f2f0;
}

.status-badge.expired,
.status-badge.failed {
  color: #91322e;
  border-color: #efc4c1;
  background: var(--red-soft);
}

.status-badge.running {
  color: #0b6874;
  border-color: #b7dce0;
  background: var(--teal-soft);
}

.status-badge.queued {
  color: #875308;
  border-color: #ecd39c;
  background: var(--amber-soft);
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.type-badge {
  color: #51436f;
  border-color: #d8cee8;
  background: #f2eef8;
}

.quota-cell {
  min-width: 116px;
}

.quota-values,
.progress-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.quota-values strong {
  color: var(--ink);
  font-size: 12px;
}

.quota-meter,
.mini-progress,
.progress-track {
  height: 5px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9e6;
}

.quota-meter span,
.mini-progress span,
.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 220ms ease;
}

.quota-meter.warning span {
  background: var(--amber);
}

.quota-meter.exhausted span {
  background: var(--red);
}

.calls-cell strong {
  display: block;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1px;
}

.row-actions .danger-action:hover {
  color: var(--red);
  border-color: #efcbc8;
  background: var(--red-soft);
}

.row-clickable {
  cursor: pointer;
}

.empty-state {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
}

.empty-state svg {
  width: 28px;
  height: 28px;
  color: #9ba49e;
}

.empty-state strong {
  font-size: 13px;
}

.filters-toolbar {
  flex-wrap: wrap;
}

.account-filter,
.ledger-account-select {
  max-width: 280px;
}

.pagination {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.pagination > div {
  display: flex;
  gap: 5px;
}

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

.ledger-event {
  display: grid;
  grid-template-columns: 34px minmax(160px, 1fr) minmax(140px, 0.7fr) 100px 140px;
  min-height: 66px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.event-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--green-dark);
  background: var(--green-soft);
}

.event-icon.adjusted {
  color: var(--amber);
  background: var(--amber-soft);
}

.event-icon.released {
  color: var(--teal);
  background: var(--teal-soft);
}

.ledger-delta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ledger-delta.negative { color: var(--red); }
.ledger-delta.positive { color: var(--green); }

.drawer-backdrop {
  position: fixed;
  z-index: 79;
  inset: 0;
  visibility: hidden;
  background: rgba(19, 25, 21, 0.28);
  opacity: 0;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.drawer-backdrop.open {
  visibility: visible;
  opacity: 1;
}

.detail-drawer {
  position: fixed;
  z-index: 80;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 94vw);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(101%);
  transition: transform 180ms ease;
}

.detail-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.drawer-header h2,
.modal-header h2,
.tool-heading h2,
.section-heading h2 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.drawer-content {
  padding: 22px;
}

.drawer-account {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-account .account-avatar {
  width: 48px;
  height: 48px;
}

.detail-list,
.result-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  padding: 18px 0;
  gap: 16px 20px;
}

.detail-list div,
.result-meta div {
  min-width: 0;
}

.detail-list dt,
.result-meta dt {
  color: var(--muted);
  font-size: 11px;
}

.detail-list dd,
.result-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 620;
}

.drawer-section {
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.drawer-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
}

.mini-event {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 44px;
}

.mini-event .event-icon {
  width: 24px;
  height: 24px;
}

.mini-event .event-icon svg {
  width: 14px;
  height: 14px;
}

.modal {
  width: min(480px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal.compact {
  width: min(420px, calc(100vw - 28px));
}

.modal.wide {
  width: min(680px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(20, 27, 22, 0.42);
}

.modal form {
  margin: 0;
  padding: 22px;
}

.modal-header,
.section-heading,
.tool-heading,
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-header {
  margin-bottom: 21px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.field {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field > span,
.field-label {
  color: #465149;
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select {
  height: 38px;
  padding: 0 10px;
}

.field textarea {
  min-height: 116px;
  padding: 10px;
  resize: vertical;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 42px;
}

.password-field .icon-btn {
  position: absolute;
  top: 2px;
  right: 2px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.modal-status {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 0 12px;
  border: 1px solid #c8e0d0;
  border-radius: 6px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
}

.import-file-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.import-file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-text-field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.import-text-field code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 500;
}

.import-text-field textarea {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
}

.import-progress {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.import-progress-heading strong {
  color: var(--ink);
  font-size: 12px;
}

.import-progress > .progress-track {
  margin-top: 9px;
}

.import-result-list {
  max-height: 220px;
  margin-top: 12px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.import-result {
  display: grid;
  min-height: 52px;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--line);
}

.import-result-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--muted);
}

.import-result-icon svg {
  width: 16px;
  height: 16px;
}

.import-result-icon .spinner {
  width: 15px;
  height: 15px;
}

.import-result.succeeded .import-result-icon,
.import-result.succeeded .import-result-state {
  color: var(--green);
}

.import-result.failed .import-result-icon,
.import-result.failed .import-result-state,
.import-result.invalid .import-result-icon,
.import-result.invalid .import-result-state {
  color: var(--red);
}

.import-result.running .import-result-state {
  color: var(--teal);
}

.import-result-copy {
  min-width: 0;
}

.import-result-copy strong,
.import-result-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-result-copy strong {
  font-size: 12px;
}

.import-result-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.import-result-state {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(24, 121, 78, 0.24);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.spinning svg {
  animation: spin 800ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.confirm-message {
  margin: 0;
  color: #4f5a53;
  line-height: 1.65;
}

.form-error {
  margin: 9px 0 0;
  color: var(--red);
  font-size: 12px;
}

.toast-region {
  position: fixed;
  z-index: 120;
  right: 20px;
  bottom: 20px;
  display: flex;
  width: min(360px, calc(100vw - 32px));
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid #bcdcc8;
  border-radius: 6px;
  color: var(--green-dark);
  background: #f2faf5;
  box-shadow: 0 10px 30px rgba(23, 32, 26, 0.12);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.error {
  color: #91322e;
  border-color: #ebc3c0;
  background: #fff5f4;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* API workbench */
.api-main {
  padding-bottom: 60px;
}

.job-lookup {
  width: min(390px, 38vw);
  height: 38px;
  padding-right: 3px;
}

.job-lookup .btn {
  min-height: 30px;
  padding: 0 11px;
}

.api-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.86fr) minmax(430px, 1.14fr);
  min-height: 650px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
}

.request-builder {
  min-width: 0;
  margin: 0;
  padding: 24px;
  border-right: 1px solid var(--line);
}

.tool-heading {
  min-height: 48px;
  margin-bottom: 18px;
}

.method-badge {
  color: #ffffff;
  border-radius: 4px;
  background: var(--green);
}

.builder-section {
  margin: 16px 0;
}

.builder-section .field-label {
  display: block;
  margin-bottom: 7px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f4f1;
}

.segmented button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.segmented button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(23, 32, 26, 0.12);
}

.request-builder > .field {
  margin-top: 15px;
}

.char-count {
  position: absolute;
  right: 8px;
  bottom: 7px;
  color: #929b95;
  background: rgba(255, 255, 255, 0.88);
  font-size: 10px;
}

.builder-submit {
  display: flex;
  min-height: 64px;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.request-state {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.response-workbench {
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: #111815;
  color: #e6eee8;
}

.response-tabs {
  display: flex;
  min-height: 48px;
  align-items: end;
  gap: 5px;
  padding: 0 14px;
  border-bottom: 1px solid #2c3731;
}

.response-tabs button {
  height: 39px;
  padding: 0 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #8f9b93;
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.response-tabs button.active {
  color: #e9f3ec;
  border-bottom-color: #55b87c;
}

.response-pane {
  display: none;
  min-width: 0;
  flex: 1;
  overflow: auto;
}

.response-pane.active {
  display: block;
}

.response-empty {
  display: flex;
  min-height: 500px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: #728078;
}

.response-empty svg {
  width: 34px;
  height: 34px;
}

.response-result {
  padding: 22px;
}

.result-header {
  min-height: 38px;
}

.result-header > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.result-header strong {
  overflow: hidden;
  color: #aeb9b1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.response-result .icon-btn,
.code-toolbar .icon-btn {
  color: #9ba89f;
}

.response-result .icon-btn:hover,
.code-toolbar .icon-btn:hover {
  color: #ffffff;
  border-color: #3b4840;
  background: #202a24;
}

.response-result .progress-track {
  margin: 14px 0 18px;
  background: #2b352f;
}

.response-result .result-meta {
  border-top: 1px solid #2d3932;
  border-bottom: 1px solid #2d3932;
}

.response-result .result-meta dt {
  color: #77847b;
}

.response-result .result-meta dd {
  color: #d9e4dc;
}

.media-output {
  margin-top: 18px;
}

.media-output img,
.media-output video,
.media-output audio {
  display: block;
  width: 100%;
  max-height: 420px;
  border: 1px solid #354139;
  border-radius: 6px;
  background: #090d0b;
  object-fit: contain;
}

.media-link {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #84d6a5;
  font-size: 12px;
}

.error-output {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #6c3734;
  border-radius: 6px;
  color: #f0b5b0;
  background: #291817;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.code-toolbar {
  display: flex;
  height: 44px;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 18px;
  color: #77847b;
  border-bottom: 1px solid #2c3731;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.response-pane pre {
  min-height: 570px;
  margin: 0;
  padding: 20px;
  overflow: auto;
  color: #c8d5cc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.model-catalog {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.section-heading {
  min-height: 54px;
  margin-bottom: 12px;
}

.model-catalog .data-table th:nth-child(1) { width: 24%; }
.model-catalog .data-table th:nth-child(2) { width: 12%; }
.model-catalog .data-table th:nth-child(3) { width: 12%; }
.model-catalog .data-table th:nth-child(4) { width: 14%; }
.model-catalog .data-table th:nth-child(5) { width: 18%; }
.model-catalog .data-table th:nth-child(6) { width: 20%; }

/* Cached media library */
.file-main { padding-bottom: 60px; }

.cache-job-form {
  display: flex;
  width: min(360px, 38vw);
  height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 3px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.cache-job-form > svg { width: 16px; color: var(--muted); }

.cache-job-form input {
  min-width: 0;
  height: 100%;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
}

.file-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 88px;
  margin: 0 -32px 24px;
  padding: 0 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.file-summary > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 14px 22px;
  border-right: 1px solid var(--line);
}

.file-summary > div:first-child { padding-left: 0; }
.file-summary > div:last-child { border-right: 0; }
.file-summary span { color: var(--muted); font-size: 11px; }
.file-summary strong { overflow: hidden; font-size: 22px; text-overflow: ellipsis; white-space: nowrap; }
.file-library { min-width: 0; }

.file-toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.file-kind-filter { width: min(430px, 60vw); }

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

.file-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.file-preview {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #e9ede9;
}

.file-preview img,
.file-preview video { width: 100%; height: 100%; object-fit: cover; }

.file-play,
.file-type-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: rgba(17, 24, 21, 0.74);
}

.file-play {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
}

.file-card-body { padding: 12px; }

.file-title,
.file-card-footer {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.file-title strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: flex;
  min-width: 0;
  gap: 7px;
  margin: 8px 0 11px;
  color: var(--muted);
  font-size: 10px;
}

.file-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-generation {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.file-generation svg { width: 14px; height: 14px; }

@media (max-width: 1200px) {
  .file-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .main-content {
    padding-right: 22px;
    padding-left: 22px;
  }

  .metrics-strip {
    margin-right: -22px;
    margin-left: -22px;
    padding-right: 22px;
    padding-left: 22px;
  }

  .quota-distribution {
    margin-right: -22px;
    margin-left: -22px;
    padding-right: 22px;
    padding-left: 22px;
  }

  .metric-item {
    padding-right: 16px;
    padding-left: 16px;
  }

  .quota-distribution-heading,
  .quota-bucket {
    padding-right: 16px;
    padding-left: 16px;
  }

  .quota-distribution-heading { padding-left: 0; }

  .api-workspace {
    grid-template-columns: minmax(320px, 0.9fr) minmax(390px, 1.1fr);
  }
}

@media (max-width: 900px) {
  :root { --sidebar-width: 78px; }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand-name,
  .nav-link span,
  .service-state span:last-child,
  .key-control span {
    display: none;
  }

  .primary-nav {
    align-items: center;
    padding-right: 8px;
    padding-left: 8px;
  }

  .nav-link,
  .key-control {
    width: 44px;
    justify-content: center;
    padding: 0;
  }

  .sidebar-footer {
    display: flex;
    align-items: center;
    flex-direction: column;
  }

  .metrics-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-item:nth-child(2) { border-right: 0; }
  .metric-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metric-item:nth-child(3) { padding-left: 0; }

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

  .quota-distribution-heading {
    grid-column: 1 / -1;
    min-height: 54px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .api-workspace {
    grid-template-columns: 1fr;
  }

  .request-builder {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .response-workbench {
    min-height: 560px;
  }

  .job-lookup {
    width: min(360px, 45vw);
  }

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

@media (max-width: 760px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    width: 224px;
    box-shadow: var(--shadow);
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar .brand {
    justify-content: flex-start;
    padding: 0 18px;
  }

  .sidebar .brand-name,
  .sidebar .nav-link span,
  .sidebar .service-state span:last-child,
  .sidebar .key-control span {
    display: flex;
  }

  .sidebar .primary-nav {
    align-items: stretch;
    padding: 18px 10px;
  }

  .sidebar .nav-link,
  .sidebar .key-control {
    width: 100%;
    justify-content: flex-start;
    padding: 0 12px;
  }

  .sidebar .sidebar-footer {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 0 16px 38px;
  }

  .mobile-menu { display: inline-flex; }

  .page-header {
    min-height: 92px;
  }

  .page-header h1 { font-size: 22px; }

  .header-actions .updated-at,
  .header-actions .secondary span {
    display: none;
  }

  .header-actions .secondary {
    width: 38px;
    padding: 0;
  }

  .metrics-strip {
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .quota-distribution {
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .metric-item {
    min-height: 96px;
    padding: 14px;
  }

  .metric-item strong { font-size: 23px; }

  .view-tabs {
    gap: 20px;
    overflow-x: auto;
  }

  .table-toolbar {
    flex-wrap: wrap;
    padding: 12px 0;
  }

  .search-field {
    min-width: 100%;
  }

  .select-control {
    min-width: 0;
    flex: 1 1 130px;
  }

  .row-count {
    width: 100%;
    margin-left: 0;
    text-align: right;
  }

  .data-table {
    min-width: 840px;
  }

  .account-table { min-width: 930px; }

  .ledger-event {
    grid-template-columns: 30px 1fr auto;
    padding: 10px 0;
  }

  .ledger-event > :nth-child(3),
  .ledger-event > :nth-child(4) { display: none; }

  .detail-list,
  .result-meta,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .job-lookup {
    width: 42px;
    min-width: 42px;
    padding: 0;
    justify-content: center;
    border-color: transparent;
    background: transparent;
  }

  .job-lookup input,
  .job-lookup .btn { display: none; }

  .api-workspace {
    margin-right: -8px;
    margin-left: -8px;
  }

  .request-builder,
  .response-result { padding: 18px; }

  .model-catalog .data-table { min-width: 760px; }

  .file-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-right: -16px;
    margin-left: -16px;
    padding: 0 16px;
  }

  .file-summary > div:nth-child(2) { border-right: 0; }
  .file-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .file-summary > div:nth-child(3) { padding-left: 0; }

  .cache-job-form {
    display: none;
  }

  .file-kind-filter { width: 100%; }
  .reference-file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .header-actions .btn.primary span { display: none; }
  .header-actions .btn.primary { width: 38px; padding: 0; }
  .metric-item { padding-right: 10px; padding-left: 10px; }
  .metric-note { font-size: 10px; }
  .quota-distribution { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quota-bucket { min-height: 62px; padding: 10px; }
  .quota-bucket:nth-child(3) { border-right: 0; }
  .quota-bucket:nth-child(2),
  .quota-bucket:nth-child(3) { border-bottom: 1px solid var(--line); }
  .modal form { padding: 18px; }
  .import-text-field > span { align-items: flex-start; flex-direction: column; gap: 3px; }
  .import-result { grid-template-columns: 22px minmax(0, 1fr) auto; gap: 7px; }
  .builder-submit { align-items: stretch; flex-direction: column; }
  .builder-submit .btn { width: 100%; }
  .file-grid { grid-template-columns: 1fr; }
  .file-toolbar { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
