:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --green-soft: #e9f8ef;
  --ink: #191919;
  --muted: #7a7a7a;
  --line: #e8e8e8;
  --canvas: #f5f6f7;
  --panel: #fff;
  --danger: #fa5151;
  --warning: #ed7b2f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f1f2f3;
}
.login-panel {
  width: min(400px, 100%);
  padding: 48px 44px 44px;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .06);
  text-align: center;
}
.brand-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  border-radius: 8px;
  background: var(--green);
  position: relative;
}
.brand-mark span { position: absolute; display: block; border-radius: 50%; background: #fff; }
.brand-mark span:first-child { width: 25px; height: 20px; left: 9px; top: 11px; }
.brand-mark span:last-child { width: 19px; height: 16px; right: 7px; bottom: 9px; border: 2px solid var(--green); }
.brand-mark.small { width: 36px; height: 36px; margin: 0; border-radius: 6px; }
.brand-mark.small span:first-child { width: 18px; height: 14px; left: 6px; top: 8px; }
.brand-mark.small span:last-child { width: 14px; height: 11px; right: 4px; bottom: 6px; border-width: 1px; }
.login-panel h1 { margin: 0; font-size: 24px; font-weight: 600; }
.login-panel > p { margin: 8px 0 34px; color: var(--muted); font-size: 14px; }
.login-panel form { text-align: left; }
.login-panel label { display: block; margin-bottom: 8px; font-size: 14px; }
.login-panel input { width: 100%; height: 44px; margin-bottom: 20px; padding: 0 14px; border: 1px solid #d8d8d8; border-radius: 4px; outline: none; }
.login-panel input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(7, 193, 96, .12); }
.form-error { min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 13px; text-align: center; }

.primary, .secondary, .text-button, .link-button, .icon-button {
  border: 0;
  border-radius: 4px;
  transition: background .15s, color .15s, border .15s;
}
.primary { min-height: 40px; padding: 0 24px; color: #fff; background: var(--green); }
.primary:hover { background: var(--green-dark); }
.primary.wide { width: 100%; }
.secondary { min-height: 34px; padding: 0 14px; border: 1px solid #d8d8d8; background: #fff; color: #333; }
.secondary:hover { border-color: #aaa; }
.text-button, .link-button { background: transparent; color: #576b95; padding: 6px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; background: transparent; color: #555; }
.icon-button:hover { background: #eee; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.sidebar-brand { height: 72px; padding: 0 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.sidebar-brand strong { font-size: 16px; font-weight: 600; white-space: nowrap; }
.sidebar nav { padding: 18px 12px; flex: 1; }
.nav-item { width: 100%; height: 44px; margin-bottom: 6px; padding: 0 14px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 4px; background: transparent; color: #555; text-align: left; }
.nav-item:hover { background: #f5f5f5; }
.nav-item.active { background: var(--green-soft); color: #05974b; font-weight: 500; }
.nav-item i, .search-box i, .icon-button i { width: 20px; height: 20px; display: inline-flex; }
.sidebar-foot { padding: 20px 26px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

.workspace { width: 100%; min-width: 0; margin-left: 220px; }
.topbar { height: 72px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 19px; font-weight: 600; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.content { width: min(1440px, 100%); padding: 28px 32px 48px; margin: 0 auto; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.metric { min-height: 126px; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.metric-label { display: flex; justify-content: space-between; align-items: center; color: #666; font-size: 13px; }
.metric-label i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px; background: var(--green-soft); color: var(--green-dark); font-style: normal; }
.metric strong { display: block; margin-top: 12px; font-size: 30px; font-weight: 500; }
.content-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(440px, 1.2fr); gap: 18px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.panel-head { min-height: 76px; padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-head p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.status-chart { padding: 26px 24px; }
.status-row { margin-bottom: 25px; }
.status-row:last-child { margin-bottom: 4px; }
.status-copy { margin-bottom: 10px; display: flex; justify-content: space-between; font-size: 13px; }
.status-copy span:last-child { color: var(--muted); }
.bar { height: 8px; overflow: hidden; border-radius: 2px; background: #f0f0f0; }
.bar span { display: block; height: 100%; min-width: 2px; background: var(--green); }
.bar.warning span { background: var(--warning); }
.bar.danger span { background: var(--danger); }
.recent-list { padding: 6px 22px; }
.recent-item { min-height: 76px; padding: 12px 0; display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 12px; border-bottom: 1px solid #f0f0f0; }
.recent-item:last-child { border-bottom: 0; }
.thumb, .thumb-placeholder { width: 50px; height: 50px; border-radius: 4px; object-fit: cover; background: #f0f1f2; }
.thumb-placeholder { display: grid; place-items: center; color: #aaa; font-size: 18px; }
.recent-copy { min-width: 0; }
.recent-copy strong { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.recent-copy span { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }
.empty { padding: 52px 24px; color: var(--muted); text-align: center; font-size: 13px; }

.settings-layout { display: grid; gap: 18px; max-width: 880px; }
.form-panel { overflow: hidden; }
.field-grid { padding: 22px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { display: block; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field > span { display: block; margin-bottom: 8px; font-size: 13px; color: #444; }
.field input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid #d8d8d8; border-radius: 4px; outline: none; }
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(7, 193, 96, .1); }
.fixed-model { min-height: 40px; padding: 0 12px; display: flex; align-items: center; gap: 12px; border: 1px solid #e2e2e2; border-radius: 4px; background: #f7f8f8; }
.fixed-model strong { font-size: 13px; font-weight: 600; }
.fixed-model code { color: #576b95; font-size: 12px; }
.fixed-model small { margin-left: auto; color: #078944; font-size: 11px; }
.test-result { min-height: 0; padding: 0 22px; color: var(--muted); font-size: 12px; }
.test-result:not(:empty) { padding-bottom: 20px; }
.test-result.success { color: #05974b; }
.test-result.error { color: var(--danger); }
.save-bar { position: sticky; bottom: 16px; padding: 14px 18px; display: flex; justify-content: flex-end; align-items: center; gap: 18px; background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
.save-bar span { color: #05974b; font-size: 13px; }

.jobs-panel, .users-panel { overflow: hidden; }
.toolbar { min-height: 70px; padding: 14px 18px; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.search-box { width: min(360px, 100%); height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 8px; border: 1px solid #d8d8d8; border-radius: 4px; color: #999; }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; }
.toolbar select { height: 38px; min-width: 130px; padding: 0 30px 0 10px; border: 1px solid #d8d8d8; border-radius: 4px; background: #fff; }
.toolbar-count { display: flex; align-items: center; color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
th { height: 46px; padding: 0 16px; background: #fafafa; color: #777; font-size: 12px; font-weight: 500; text-align: left; }
td { min-height: 70px; padding: 12px 16px; border-top: 1px solid #f0f0f0; font-size: 13px; }
.job-main { width: 330px; display: flex; align-items: center; gap: 12px; }
.job-main .recent-copy strong { width: 260px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 3px; background: #f0f0f0; color: #666; font-size: 12px; }
.badge.completed { background: var(--green-soft); color: #05974b; }
.badge.failed { background: #fff0f0; color: var(--danger); }
.badge.processing, .badge.queued { background: #fff5eb; color: var(--warning); }
.users-table { min-width: 1080px; }
.user-main { min-width: 230px; display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 42px; height: 42px; flex: none; border-radius: 6px; object-fit: cover; background: #f0f1f2; }
.user-avatar.fallback { display: grid; place-items: center; background: var(--green-soft); color: #078944; font-size: 16px; font-weight: 600; }
.user-main strong, .user-main span { display: block; }
.user-main strong { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.user-main span { max-width: 190px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; }
.quota-usage { color: #555; font-variant-numeric: tabular-nums; }
.quota-balance { color: #05974b; font-size: 16px; font-weight: 600; }
.quota-form { display: flex; align-items: center; gap: 8px; }
.quota-form input { width: 82px; height: 34px; padding: 0 9px; border: 1px solid #d8d8d8; border-radius: 4px; outline: none; }
.quota-form input:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(7, 193, 96, .1); }
.quota-form button:disabled { cursor: wait; opacity: .55; }

.toast { position: fixed; left: 50%; bottom: 38px; z-index: 100; transform: translate(-50%, 16px); padding: 11px 18px; border-radius: 4px; background: rgba(20, 20, 20, .9); color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .sidebar { width: 72px; }
  .sidebar-brand { padding: 0 18px; }
  .sidebar-brand strong, .nav-item span, .sidebar-foot span { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-foot { justify-content: center; padding: 20px 0; }
  .workspace { margin-left: 72px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar { inset: auto 0 0; width: auto; height: 58px; border: 0; border-top: 1px solid var(--line); flex-direction: row; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .sidebar nav { width: 100%; padding: 4px 10px; display: flex; }
  .nav-item { height: 48px; margin: 0; flex: 1; }
  .nav-item span { display: block; font-size: 11px; }
  .workspace { margin: 0 0 58px; }
  .topbar { height: 66px; padding: 0 16px; }
  .topbar p { display: none; }
  .content { padding: 16px; }
  .metrics-grid { gap: 10px; }
  .metric { min-height: 104px; padding: 16px; }
  .metric strong { font-size: 24px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
  .toolbar { flex-direction: column; }
  .search-box { width: 100%; }
}
