:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee6;
  --brand: #1d4ed8;
  --brand-dark: #163a8a;
  --success: #087443;
  --success-bg: #e7f7ef;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --active: #b54708;
  --active-bg: #fff4e5;
}

.auth-panel {
  width: min(100%, 440px);
  margin: 48px auto;
  padding: 24px;
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form input,
.auth-form select {
  width: 100%;
  box-sizing: border-box;
}

.success {
  color: #177245;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell { min-height: 100vh; }
.auth-container { min-height: 100vh; padding: 20px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 224px;
  flex-direction: column;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 8px 18px;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid #edf0f3;
  border-radius: 8px;
  background: white;
  object-fit: cover;
}

.side-nav { display: grid; gap: 4px; }

.side-nav > a,
.side-nav > span {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 9px;
  min-height: 44px;
  align-items: center;
  align-content: center;
  padding: 8px 12px;
  border-radius: 6px;
  color: #344054;
  text-decoration: none;
}

.nav-icon {
  width: 18px;
  height: 18px;
  color: currentColor;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-nav > a:hover,
.side-nav > a.active {
  background: #eef3ff;
  color: var(--brand-dark);
  font-weight: 700;
}

.admin-nav-group {
  display: grid;
  gap: 4px;
}

.admin-nav-title {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 9px;
  min-height: 40px;
  align-items: center;
  padding: 8px 12px 4px;
  color: #344054;
  font-weight: 700;
}

.admin-nav-children {
  display: grid;
  gap: 3px;
  padding-left: 29px;
}

.admin-nav-children a {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  color: #475467;
  text-decoration: none;
}

.admin-nav-children a:hover,
.admin-nav-children a.active {
  background: #eef3ff;
  color: var(--brand-dark);
  font-weight: 700;
}

.side-nav small { display: block; margin-top: 2px; color: #98a2b3; font-size: 11px; }
.nav-disabled { cursor: not-allowed; color: #98a2b3 !important; background: #f8f9fb; }
.sidebar-user { display: grid; gap: 4px; margin-top: auto; padding: 14px 12px 0; border-top: 1px solid var(--line); font-size: 13px; }
.sidebar-user span { color: var(--muted); }
.mobile-nav { display: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: #111827;
  color: #fff;
}

.brand {
  font-weight: 700;
}

.topbar nav {
  display: flex;
  gap: 18px;
}

.topbar a {
  color: #fff;
  text-decoration: none;
}

.container {
  max-width: 1180px;
  margin: 0 auto 0 calc(224px + max(0px, (100vw - 1404px) / 2));
  padding: 28px 24px 48px;
}

.workbench-metrics { margin-bottom: 18px; }
.workbench-metrics strong { font-size: 26px; }
.analysis-form-panel { max-width: 880px; }
.task-filter-form { grid-template-columns: minmax(150px, 1fr) repeat(2, minmax(160px, 1fr)) auto; }

.cost-reminder {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-actions,
.browser-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.browser-actions {
  margin: 16px 0;
}

.browser-actions form {
  margin: 0;
}

.browser-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.browser-status-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.browser-status-grid dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.browser-status-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.submit-panel {
  padding: 20px;
}

.platform-selector {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid #c9d2df;
  border-radius: 9px;
  background: #f3f6fb;
}

.task-form .platform-option {
  position: relative;
  margin: 0;
  color: var(--text);
  cursor: pointer;
}

.platform-option input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  opacity: 0;
}

.platform-option span {
  display: inline-flex;
  min-width: 76px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border-radius: 6px;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.platform-option input:checked + span {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 6px rgb(37 83 235 / 20%);
}

.platform-option input:focus-visible + span {
  outline: 3px solid rgb(37 83 235 / 28%);
  outline-offset: 2px;
}

.task-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #c9d2df;
  border-radius: 6px;
  font-size: 15px;
}

select {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #c9d2df;
  border-radius: 6px;
  background: white;
  font-size: 15px;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.usage-filter-form {
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
}

.usage-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 1px;
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--line);
}

.usage-summary-grid > div {
  display: grid;
  gap: 7px;
  min-height: 88px;
  padding: 14px;
  background: var(--panel);
}

.usage-summary-grid span,
.history-note {
  color: var(--muted);
  font-size: 13px;
}

.usage-summary-grid strong {
  font-size: 17px;
}

.history-note {
  margin: 14px 0 0;
}

.audit-details {
  max-width: 320px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.filter-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.admin-table {
  min-width: 0;
  table-layout: fixed;
}

.admin-table-wrap {
  max-height: none;
  overflow-x: hidden;
}

.management-actions {
  display: grid;
  grid-template-columns: minmax(310px, 1.7fr) minmax(145px, 0.8fr) minmax(112px, 0.6fr);
  align-items: center;
  gap: 6px;
}

.management-actions form,
.inline-management-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.inline-management-form input,
.inline-management-form select {
  width: auto;
  min-height: 36px;
  max-width: 140px;
  padding: 7px 9px;
  font-size: 13px;
}

.management-actions input[name="full_name"] {
  max-width: 110px;
}

.management-actions input[name="temporary_password"] {
  max-width: 130px;
}

.management-actions button {
  min-height: 36px;
  white-space: nowrap;
}

.admin-table th,
.admin-table td {
  padding: 10px 8px;
}

.admin-table th:nth-child(1),
.admin-table td:nth-child(1) {
  width: 86px;
}

.admin-table th:nth-child(2),
.admin-table td:nth-child(2) {
  width: 70px;
}

.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
  width: 76px;
}

.admin-table th:nth-child(4),
.admin-table td:nth-child(4) {
  width: 72px;
}

.admin-table th:nth-child(5),
.admin-table td:nth-child(5) {
  width: 52px;
}

.admin-table th:nth-child(6),
.admin-table td:nth-child(6) {
  width: 126px;
}

.admin-table th:nth-child(7),
.admin-table td:nth-child(7) {
  width: auto;
}

.admin-table td {
  overflow-wrap: anywhere;
}

.activity-cell {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.compact-number {
  font-weight: 700;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #8a1f16;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding-top: 14px;
  color: var(--muted);
}

.pagination div {
  display: flex;
  gap: 8px;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

button,
.button,
.row-action,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

button,
.button {
  border: 0;
  background: var(--brand);
  color: white;
}

button:hover,
.button:hover {
  background: var(--brand-dark);
}

.button.secondary,
.row-action,
.ghost-link {
  border: 1px solid #c9d2df;
  background: white;
  color: #1849a9;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #edf0f3;
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status.success {
  color: var(--success);
  background: var(--success-bg);
}

.status.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.status.active {
  color: var(--active);
  background: var(--active-bg);
}

.status.muted {
  color: #344054;
  background: #eef2f6;
}

.hint {
  display: inline-block;
  margin-left: 6px;
  color: #1849a9;
  font-size: 12px;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.task-compact-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.task-summary-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.task-summary-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.task-compact-summary dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px 18px;
  margin: 0;
}

.task-compact-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.task-compact-summary dd {
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.task-more-meta {
  color: var(--muted);
  font-size: 13px;
}

.task-more-meta summary {
  cursor: pointer;
}

.task-more-meta dl {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.metric {
  min-width: 0;
  padding: 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  color: #1849a9;
  background: #eaf1ff;
  border: 1px solid #c7d7fe;
  border-radius: 6px;
}

.error {
  color: var(--danger);
}

.banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--danger-bg);
  border: 1px solid #fecdca;
  border-radius: 6px;
}

.banner.success {
  color: #067647;
  background: #ecfdf3;
  border-color: #abefc6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

iframe {
  width: 100%;
  min-height: min(760px, calc(100vh - 260px));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.section-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.logs {
  list-style: none;
  padding: 0;
  margin: 0;
}

.logs li {
  display: grid;
  grid-template-columns: 160px 58px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0f3;
}

.log-time,
.log-level,
.empty {
  color: var(--muted);
}

.config-list {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px 18px;
  margin: 0;
}

.config-list dt {
  color: var(--muted);
}

.config-list dd {
  margin: 0;
}

.balance-card {
  max-width: 680px;
}

.balance-value {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 6px;
}

.balance-value span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.balance-value strong {
  font-size: 32px;
  line-height: 1.1;
}

@media (max-width: 760px) {
  .sidebar { display: none; }

  .mobile-nav {
    display: block;
    margin: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
  }

  .mobile-nav summary { cursor: pointer; font-weight: 700; }
  .mobile-nav nav { display: grid; gap: 6px; padding-top: 12px; }
  .mobile-nav a { padding: 8px 0; color: var(--text); text-decoration: none; }
  .mobile-admin-nav { display: grid; gap: 6px; }
  .mobile-admin-nav strong { padding-top: 4px; }
  .mobile-admin-nav a { padding-left: 14px; }

  .topbar,
  .page-head,
  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .input-row,
  .filter-form,
  .summary-grid,
  .task-compact-summary dl,
  .task-more-meta dl,
  .browser-status-grid,
  .logs li,
  .config-list {
    grid-template-columns: 1fr;
  }

  .task-summary-main {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-summary-main strong,
  .task-compact-summary dd {
    white-space: normal;
  }

  .container {
    margin: 0;
    padding: 20px 14px 36px;
  }

  h1 {
    font-size: 24px;
  }
}
