:root {
  --blue: #1769aa;
  --blue-soft: #eaf3fa;
  --blue-mid: #2d7fbd;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --line: #e1e5e9;
  --line-strong: #cbd2d9;
  --text: #202830;
  --muted: #68737d;
  --danger: #c53d43;
  --green: #16866b;
  --amber: #a86708;
  --shadow: 0 10px 28px rgba(32, 40, 48, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Source Han Sans", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-logo {
  display: block;
  width: 210px;
  height: 70px;
  object-fit: contain;
  margin: 0 auto 16px;
}

.auth-panel h1 {
  margin: 0 0 24px;
  font-size: 24px;
  line-height: 1.25;
  text-align: center;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 0 10px;
}

textarea {
  min-height: 86px;
  resize: vertical;
  padding-top: 9px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.primary-button,
.ghost-button,
.danger-button,
.success-button,
.small-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  white-space: nowrap;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover {
  background: #12588f;
}

.success-button {
  background: var(--green);
  color: #fff;
}

.ghost-button {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--blue);
}

.danger-button {
  border-color: #ffd0d0;
  background: #fff5f5;
  color: var(--danger);
}

.admin-dialog-backdrop {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(16, 35, 63, 0.34);
}

.admin-dialog {
  width: min(440px, calc(100vw - 48px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(16, 35, 63, 0.24);
}

.admin-dialog header {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 18px 20px 12px;
}

.admin-dialog-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--danger);
  background: #fff0f0;
  font-weight: 900;
}

.admin-dialog header > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.admin-dialog header span:not(.admin-dialog-mark) {
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.admin-dialog h2 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-dialog p {
  margin: 0 20px 18px;
  color: #42506a;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.admin-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 20px 18px;
  background: #fbfdff;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--blue);
}

.error-text {
  min-height: 20px;
  margin: -2px 0 12px;
  color: var(--danger);
  font-size: 13px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 8px;
}

.brand strong {
  display: block;
  font-size: 20px;
  line-height: 1.15;
}

.brand span,
.admin-actions span {
  color: var(--muted);
  font-size: 13px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: calc(100vh - 64px);
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.nav-group + .nav-group {
  margin-top: 18px;
}

.nav-heading {
  display: block;
  padding: 0 12px 7px;
  color: #8a949d;
  font-size: 11px;
  font-weight: 700;
}

.nav-button {
  width: 100%;
  height: 40px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 14px;
}

.nav-button.is-active {
  border-color: #bdd7ff;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

.nav-button:hover:not(.is-active) {
  background: #f4f6f8;
}

.content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 22px 24px 40px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.page-head h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.page-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(32, 40, 48, 0.04);
  margin-bottom: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.panel-body {
  padding: 14px 16px 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.form-grid.announcement {
  grid-template-columns: minmax(160px, 0.8fr) minmax(260px, 1.4fr) minmax(180px, 0.8fr) auto auto;
}

.form-grid.ai-config {
  grid-template-columns: minmax(280px, 1fr) auto auto;
}

.form-grid.ai-config .ai-token-field {
  min-width: 0;
}

.config-hints {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: 220px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #fbfdff;
  position: sticky;
  top: 0;
  z-index: 2;
}

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #fff;
  box-shadow: -1px 0 0 var(--line);
}

th:last-child {
  z-index: 3;
  background: #f8fafb;
}

td input,
td select {
  min-height: 30px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
  font-size: 12px;
}

.badge.green {
  background: #ddfbf4;
  color: #049779;
}

.badge.red {
  background: #fff0f0;
  color: var(--danger);
}

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

.metric-card {
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: 7px;
  background: #fff;
}

.metric-card > span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.metric-card.is-success {
  border-top-color: var(--green);
}

.metric-card.is-warning {
  border-top-color: var(--amber);
}

.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 14px;
  align-items: start;
}

.overview-main {
  min-width: 0;
}

.overview-side {
  display: grid;
  gap: 14px;
}

.overview-side .panel {
  margin-bottom: 0;
}

.compact-table {
  min-width: 640px;
}

.compact-table td:first-child strong {
  display: block;
  margin-bottom: 3px;
}

.quick-actions,
.health-list {
  display: grid;
}

.quick-actions button,
.health-list button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.quick-actions button:last-child,
.health-list button:last-child {
  border-bottom: 0;
}

.quick-actions button {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 12px 16px;
}

.quick-actions button:hover,
.health-list button:hover {
  background: #f7f9fa;
}

.quick-actions strong {
  font-size: 13px;
}

.quick-actions span {
  color: var(--muted);
  font-size: 12px;
}

.health-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 16px;
}

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

.health-list strong {
  font-size: 13px;
}

.warning-text {
  color: var(--amber);
}

.success-text {
  color: var(--green);
}

.danger-text {
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.generated-codes {
  margin-top: 12px;
}

.generated-codes textarea {
  font-family: Consolas, "Courier New", monospace;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 14px;
  color: var(--muted);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  color: var(--text);
}

.checkbox-line input {
  min-height: 0;
  width: 16px;
  height: 16px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2000;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(16, 35, 63, 0.92);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  pointer-events: none;
}

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

  .sidebar {
    display: flex;
    position: static;
    min-height: auto;
    gap: 10px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-group {
    display: flex;
    gap: 6px;
  }

  .nav-group + .nav-group {
    margin-top: 0;
  }

  .nav-heading {
    display: none;
  }

  .nav-button {
    width: auto;
    min-width: 110px;
    margin-bottom: 0;
    text-align: center;
  }

  .form-grid,
  .form-grid.three,
  .form-grid.announcement,
  .form-grid.ai-config {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid.ai-config .ai-token-field {
    grid-column: 1 / -1;
  }

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

  .overview-layout {
    grid-template-columns: 1fr;
  }

  .overview-side {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .page-head,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    height: auto;
    padding: 14px;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
  }

  .form-grid,
  .form-grid.three,
  .form-grid.announcement,
  .form-grid.ai-config {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px 12px 28px;
  }

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

  .metric-card {
    min-height: 108px;
  }

  .page-head > button {
    width: 100%;
  }
}

/* Professional operations shell */
:root {
  --blue: #2563eb;
  --blue-soft: #eef4ff;
  --blue-mid: #2563eb;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #171a1f;
  --muted: #6b7280;
  --danger: #c9363e;
  --green: #12805c;
  --amber: #a15c07;
  --shadow: 0 8px 24px rgba(20, 24, 31, 0.06);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.auth-shell {
  background: #f2f3f5;
}

.auth-panel {
  width: min(400px, 100%);
  padding: 36px;
  border-color: #dedfe3;
  box-shadow: 0 18px 50px rgba(20, 24, 31, 0.09);
}

.auth-logo {
  width: 180px;
  height: 56px;
  margin-bottom: 22px;
}

.auth-panel h1 {
  margin-bottom: 28px;
  font-size: 21px;
}

input,
select,
textarea {
  border-color: var(--line-strong);
  border-radius: 5px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.primary-button,
.ghost-button,
.danger-button,
.success-button,
.small-button {
  min-height: 34px;
  border-radius: 5px;
  font-weight: 600;
}

.primary-button {
  background: var(--blue);
}

.primary-button:hover {
  background: #1d4ed8;
}

.ghost-button,
.small-button {
  border-color: var(--line-strong);
  background: #fff;
  color: #374151;
}

.ghost-button:hover,
.small-button:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.admin-app {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: 228px;
  min-height: 100vh;
  padding: 0;
  border: 0;
  background: #181b20;
  color: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 68px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: contain;
}

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

.sidebar-brand strong {
  font-size: 16px;
  line-height: 1.25;
}

.sidebar-brand span {
  margin-top: 2px;
  color: #7f8996;
  font-size: 9px;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px;
}

.nav-group + .nav-group {
  margin-top: 22px;
}

.nav-heading {
  padding: 0 10px 8px;
  color: #737d89;
  font-size: 10px;
  font-weight: 700;
}

.nav-button {
  position: relative;
  height: 38px;
  margin: 2px 0;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  color: #aeb6c0;
  font-size: 13px;
}

.nav-button:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.05);
  color: #f3f4f6;
}

.nav-button.is-active {
  border: 0;
  background: #2563eb;
  color: #fff;
  font-weight: 650;
}

.sidebar-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #7f8996;
  font-size: 11px;
}

.sidebar-status strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #aeb6c0;
  font-size: 11px;
}

.sidebar-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #36b37e;
  box-shadow: 0 0 0 3px rgba(54, 179, 126, 0.12);
}

.admin-main {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.workspace-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.workspace-title span {
  color: #9ca3af;
}

.workspace-title span::after {
  content: "/";
  margin-left: 8px;
  color: #d1d5db;
}

.workspace-title strong {
  color: #374151;
  font-weight: 600;
}

.admin-actions span {
  color: #4b5563;
  font-size: 12px;
}

.content {
  max-width: 1540px;
  padding: 26px 28px 44px;
}

.page-head {
  align-items: center;
  margin-bottom: 18px;
}

.page-head h2 {
  margin-bottom: 5px;
  font-size: 21px;
  font-weight: 680;
}

.page-head p {
  color: #7b838c;
  font-size: 12px;
}

.page-kicker {
  margin-bottom: 5px;
  color: #8b949e;
  font-size: 10px;
  font-weight: 750;
}

.panel {
  border-color: var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(20, 24, 31, 0.025);
}

.panel-title {
  min-height: 46px;
  padding: 0 15px;
  color: #30363d;
  font-size: 13px;
  font-weight: 650;
}

.panel-body {
  padding: 15px;
}

.metric-grid {
  gap: 10px;
  margin-bottom: 16px;
}

.metric-card {
  min-height: 112px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(20, 24, 31, 0.025);
}

.metric-card::after {
  content: "";
  display: block;
  width: 24px;
  height: 2px;
  margin-top: 12px;
  background: #2563eb;
}

.metric-card.is-success::after {
  background: var(--green);
}

.metric-card.is-warning::after {
  background: var(--amber);
}

.metric-card strong {
  margin: 8px 0 6px;
  font-size: 27px;
  font-weight: 650;
}

.metric-card > span,
.metric-card small {
  font-size: 11px;
}

.overview-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.overview-side {
  gap: 12px;
}

.quick-actions button,
.health-list button {
  border-color: #eceef0;
}

.quick-actions button:hover,
.health-list button:hover {
  background: #f8f9fb;
}

.table-wrap {
  scrollbar-color: #c8cdd3 transparent;
  scrollbar-width: thin;
}

table {
  min-width: 920px;
}

th,
td {
  padding: 9px 11px;
  font-size: 12px;
}

th {
  color: #68707a;
  background: #f8f9fa;
  font-size: 11px;
  font-weight: 650;
}

tr:hover td {
  background: #fafbfc;
}

td:last-child,
th:last-child {
  background: #fff;
}

tr:hover td:last-child {
  background: #fafbfc;
}

.compact-table {
  min-width: 640px;
}

.badge {
  height: 22px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10px;
}

.toolbar {
  margin-bottom: 14px;
}

.form-grid.ai-config {
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 1fr) auto auto;
}

.ai-connection-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid #9ca3af;
  border-radius: 5px;
  background: #fafbfc;
}

.ai-connection-status[data-state="success"] {
  border-left-color: var(--green);
}

.ai-connection-status[data-state="error"] {
  border-left-color: var(--danger);
  background: #fffafa;
}

.ai-connection-status > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ai-connection-status strong {
  font-size: 12px;
}

.ai-connection-status span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}

.toolbar input,
.toolbar select {
  width: 190px;
}

.pagination {
  justify-content: flex-end;
  color: #7b838c;
  font-size: 11px;
}

.toast {
  border-radius: 5px;
  background: #252a31;
  box-shadow: 0 14px 32px rgba(20, 24, 31, 0.2);
}

.toast[data-tone="success"] {
  border-left: 3px solid #36b37e;
}

.toast[data-tone="error"] {
  border-left: 3px solid #e65b63;
  background: #2b2022;
}

button.is-busy {
  position: relative;
  color: transparent !important;
}

button.is-busy::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 13px;
  height: 13px;
  margin: -7px 0 0 -7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: #6b7280;
  animation: admin-button-spin 0.7s linear infinite;
}

.primary-button.is-busy::after {
  color: #fff;
}

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

@media (max-width: 960px) {
  .admin-app {
    display: block;
  }

  .sidebar {
    position: static;
    display: block;
    width: 100%;
    min-height: auto;
  }

  .sidebar-brand {
    height: 58px;
  }

  .sidebar-nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 12px;
  }

  .nav-group {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }

  .nav-group + .nav-group {
    margin-top: 0;
  }

  .nav-heading,
  .sidebar-status {
    display: none;
  }

  .nav-button {
    width: auto;
    min-width: 96px;
    margin: 0;
    text-align: center;
  }

  .admin-main {
    min-width: 0;
  }

  .topbar {
    position: static;
  }

  .overview-layout {
    grid-template-columns: 1fr;
  }

  .overview-side {
    grid-template-columns: 1fr 1fr;
  }

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

  .form-grid.ai-config .ai-base-field,
  .form-grid.ai-config .ai-token-field {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .sidebar-brand {
    padding: 0 14px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    height: 56px;
    padding: 0 14px;
  }

  .workspace-title {
    display: none;
  }

  .admin-actions {
    width: 100%;
    justify-content: space-between;
  }

  .content {
    padding: 18px 12px 30px;
  }

  .page-head {
    align-items: stretch;
  }

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

  .metric-card {
    min-height: 104px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
  }

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

  .ai-connection-status {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-connection-status button {
    width: 100%;
  }
}
