:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #17201b;
  --muted: #68746f;
  --line: #d9e1dc;
  --green: #0f7a55;
  --green-soft: #dcefe6;
  --amber: #a35d06;
  --amber-soft: #f7ead8;
  --red: #b42318;
  --red-soft: #f8dfdc;
  --blue: #315b8f;
  --blue-soft: #e2ebf7;
  --shadow: 0 16px 48px rgba(28, 40, 32, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon-sprite {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #17201b;
  color: #f8fbf8;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-height: 44px;
  padding: 0 6px 22px;
}

.brand-mark {
  align-items: center;
  background: #f8fbf8;
  color: #17201b;
  display: grid;
  font-size: 13px;
  font-weight: 800;
  height: 34px;
  place-items: center;
  width: 34px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aab8b1;
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  align-items: center;
  background: transparent;
  border: 0;
  color: #cad6d0;
  display: flex;
  gap: 10px;
  min-height: 40px;
  padding: 0 10px;
  text-align: left;
  width: 100%;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-item svg,
.icon-button svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.side-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: auto;
  padding: 16px 8px 0;
}

.label,
.eyebrow,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.label,
.eyebrow {
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.side-footer .label {
  color: #aab8b1;
  display: block;
}

.side-footer strong {
  font-size: 13px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-head,
.panel-head,
.tenant-row,
.top-actions,
.filter-row,
.dialog-actions {
  align-items: center;
  display: flex;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 24px;
}

.tenant-row,
.top-actions,
.filter-row,
.dialog-actions {
  gap: 10px;
}

.top-actions {
  min-width: 0;
}

.support-token-row {
  flex-wrap: wrap;
  width: 100%;
}

.support-token-row input {
  flex: 1 1 220px;
  min-width: 0;
}

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

.support-action-form label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
  min-width: 0;
}

.support-action-form input,
.support-action-form textarea,
.dialog-card textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  min-height: 38px;
  min-width: 0;
  padding: 8px 10px;
}

.support-action-form textarea,
.dialog-card textarea {
  min-height: 72px;
  resize: vertical;
}

.support-action-form .span-form,
.support-action-form button {
  grid-column: 1 / -1;
}

.dispatch-workline {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.notice {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  max-width: 320px;
  min-height: 38px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tenant-row select,
.filter-row input,
.inline-form input,
.dialog-card select,
.compact-select {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 38px;
  padding: 0 10px;
}

.inline-action {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  min-width: 220px;
}

.inline-action .compact-select {
  min-width: 116px;
}

.status-pill,
.tag {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 26px;
  padding: 0 10px;
  white-space: nowrap;
}

.status-pill.ok,
.tag.ok {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warn,
.tag.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.blocked,
.tag.blocked {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.info,
.tag.info {
  background: var(--blue-soft);
  color: var(--blue);
}

.icon-button,
.text-button,
.primary-button {
  align-items: center;
  border: 1px solid var(--line);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
}

.icon-button {
  background: var(--surface);
  color: var(--ink);
  width: 38px;
}

.text-button,
.primary-button {
  padding: 0 12px;
}

.text-button {
  background: var(--surface);
  color: var(--ink);
}

.text-button.disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.7;
}

.billing-action {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
}

.billing-action span {
  color: var(--muted);
  flex: 1 1 180px;
  font-size: 13px;
}

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

.invite-body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.invite-panel .panel-head {
  flex-wrap: wrap;
  gap: 12px;
}

.inline-form {
  align-items: center;
  display: flex;
  gap: 10px;
}

.inline-form input {
  flex: 1 1 280px;
  min-height: 38px;
  min-width: 0;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

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

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 15px;
}

h3 {
  font-size: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 114px;
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  margin: 8px 0;
}

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

.content-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.panel {
  overflow: hidden;
}

.panel > h2,
.panel-head {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-head {
  justify-content: space-between;
}

.list,
.table-wrap {
  display: grid;
}

.list-item {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 62px;
  padding: 12px 16px;
}

.list-item:last-child {
  border-bottom: 0;
}

.item-meta,
.subtle {
  color: var(--muted);
  font-size: 12px;
}

.item-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

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

tr:last-child td {
  border-bottom: 0;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.token-reveal {
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  border-radius: 8px;
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
}

.token-reveal code {
  overflow-wrap: anywhere;
}

.progress {
  background: var(--surface-2);
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
}

.progress > span {
  background: var(--green);
  display: block;
  height: 100%;
}

.segmented {
  background: var(--surface);
  border: 1px solid var(--line);
  display: inline-flex;
  min-height: 38px;
  padding: 3px;
}

.segmented button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
}

.segmented button.active {
  background: var(--green-soft);
  color: var(--green);
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.dialog-card {
  display: grid;
  gap: 16px;
  min-width: min(420px, calc(100vw - 32px));
  padding: 20px;
}

.dialog-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.dialog-context {
  color: var(--muted);
  font-size: 13px;
}

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

  .sidebar {
    height: auto;
    position: static;
  }

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

  .metric-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

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

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

  table {
    min-width: 720px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .support-token-row input {
    flex-basis: 100%;
  }

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

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

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

  .inline-form input {
    flex: 0 1 auto;
    width: 100%;
  }

  .support-token-row .text-button {
    flex: 1 1 0;
  }
}
