:root {
  --blue: #1677ff;
  --blue-strong: #0958d9;
  --blue-soft: #eaf3ff;
  --green: #12a574;
  --red: #e5484d;
  --amber: #d97706;
  --ink: #172033;
  --muted: #68758a;
  --line: #e4e9f1;
  --soft: #f6f8fb;
  --white: #fff;
  --sidebar: 220px;
  --topbar: 58px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, "Microsoft YaHei", system-ui, sans-serif; color: var(--ink); background: var(--soft); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(30, 50, 80, .05); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.brand > span:last-child { display: flex; align-items: baseline; gap: 9px; }
.brand strong { font-size: 20px; letter-spacing: 0; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #1677ff 20%, #13b8a6 75%, #ff5f6d); border-radius: 7px; }
.brand-mark svg { width: 22px; height: 22px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.system-state { font-size: 12px; color: var(--green); display: flex; align-items: center; gap: 7px; }
.pulse { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 4px rgba(18,165,116,.12); }

.sidebar { position: fixed; top: var(--topbar); bottom: 0; left: 0; width: var(--sidebar); z-index: 20; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-label { margin: 18px 12px 7px; color: #a0a9b8; font-size: 11px; }
.nav-item { width: 100%; height: 42px; border: 0; border-radius: 6px; background: transparent; color: #425069; display: flex; align-items: center; gap: 11px; padding: 0 12px; margin-bottom: 3px; text-align: left; }
.nav-item:hover { background: var(--soft); color: var(--blue); }
.nav-item.active { color: var(--blue); background: var(--blue-soft); font-weight: 600; }
.nav-item b { margin-left: auto; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: grid; place-items: center; background: #eef1f5; color: var(--muted); font-size: 11px; }
.nav-item.active b { background: var(--blue); color: #fff; }
.sidebar-footer { height: 64px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.sidebar-footer .avatar { width: 32px; height: 32px; display: grid; place-items: center; background: #172033; color: #fff; border-radius: 50%; font-size: 13px; }
.sidebar-footer div:last-child { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.sidebar-footer small { color: var(--muted); }

.workspace { margin-left: var(--sidebar); padding-top: var(--topbar); min-height: 100vh; }
.page { padding: 22px 26px 38px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.page-head h1 { margin: 0 0 5px; font-size: 22px; letter-spacing: 0; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 9px; }

button.primary, button.secondary, button.ghost, button.danger, .text-button, .icon-button { border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 5px; height: 36px; padding: 0 14px; }
button.primary { background: var(--blue); color: #fff; }
button.primary:hover { background: var(--blue-strong); }
button.secondary { background: #fff; border-color: #b8d4fb; color: var(--blue); }
button.ghost { background: #fff; border-color: var(--line); color: #334158; }
button.danger { background: #fff; border-color: #ffc9cc; color: var(--red); }
.text-button { background: transparent; color: var(--blue); padding: 0 4px; height: 30px; }
.icon-button { width: 34px; padding: 0; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--soft); color: var(--ink); }
button.wide { width: 100%; }
button:disabled { opacity: .45; cursor: not-allowed; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); border: 1px solid var(--line); background: #fff; margin-bottom: 18px; }
.metric { padding: 17px 19px; min-height: 102px; border-right: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; align-items: center; }
.metric:last-child { border-right: 0; }
.metric .label { color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 28px; margin-top: 8px; }
.metric .metric-icon { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 16px; }
.split > *, .section { min-width: 0; }
.section { background: #fff; border: 1px solid var(--line); margin-bottom: 16px; }
.section-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head p { color: var(--muted); font-size: 12px; margin: 3px 0 0; }
.section-body { padding: 16px; }
.section-body.flush { padding: 0; }

.flow-track { display: grid; grid-template-columns: repeat(5, 1fr); }
.flow-step { position: relative; padding: 18px 14px; text-align: center; border-right: 1px solid var(--line); }
.flow-step:last-child { border-right: 0; }
.flow-step .step-icon { margin: 0 auto 9px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.flow-step strong { display: block; font-size: 13px; }
.flow-step small { color: var(--muted); font-size: 11px; }

.integration-list { display: grid; gap: 10px; }
.integration { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.integration:last-child { border-bottom: 0; }
.integration .provider-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: var(--soft); color: #53627a; }
.integration strong { font-size: 13px; display: block; }
.integration small { color: var(--muted); font-size: 11px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.status-dot.ready { color: var(--green); }
.status-dot.ready::before { background: var(--green); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filters, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
input, select { height: 36px; border: 1px solid #d8dee8; border-radius: 5px; background: #fff; padding: 0 10px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: #7bb2fb; box-shadow: 0 0 0 3px rgba(22,119,255,.08); }
.search { width: 250px; }
label { display: block; font-size: 12px; color: #4b5870; margin-bottom: 6px; }

.table-wrap { width: 100%; overflow: auto; }
table { border-collapse: collapse; width: 100%; min-width: 820px; }
th { height: 43px; background: #fafbfc; color: #607089; font-weight: 500; font-size: 12px; text-align: left; border-bottom: 1px solid var(--line); padding: 0 14px; white-space: nowrap; }
td { height: 55px; border-bottom: 1px solid #edf0f5; padding: 8px 14px; font-size: 12px; vertical-align: middle; }
tr:hover td { background: #fbfdff; }
.checkbox { width: 16px; height: 16px; accent-color: var(--blue); }
.cell-title { max-width: 300px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 3px; font-size: 11px; color: var(--blue); background: var(--blue-soft); }
.tag.green { color: #087a55; background: #e8f8f1; }
.tag.amber { color: #9a5b00; background: #fff4dc; }
.tag.gray { color: #68758a; background: #eef1f5; }
.tag.red { color: #b4232a; background: #ffeaeb; }
.link-action { border: 0; background: none; color: var(--blue); padding: 2px 5px; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 38px; height: 38px; margin-bottom: 10px; color: #b4becd; }

.wizard { display: grid; grid-template-columns: 240px minmax(0,1fr); min-height: 560px; }
.wizard-nav { background: #fafbfc; border-right: 1px solid var(--line); padding: 14px; }
.wizard-nav button { width: 100%; display: grid; grid-template-columns: 30px 1fr; gap: 9px; align-items: center; text-align: left; border: 0; background: transparent; padding: 11px; border-radius: 5px; color: var(--muted); }
.wizard-nav button.active { background: #fff; color: var(--blue); box-shadow: 0 1px 4px rgba(25,50,80,.08); }
.wizard-nav b { grid-row: 1 / span 2; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #e8edf4; font-size: 12px; }
.wizard-nav button.active b { background: var(--blue); color: #fff; }
.wizard-nav strong { font-size: 13px; }
.wizard-nav small { font-size: 10px; }
.wizard-content { padding: 22px; }
.wizard-content h2 { font-size: 17px; margin: 0 0 5px; }
.wizard-content > p { color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; max-width: 760px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid input, .form-grid select { width: 100%; }
.choice-list { border: 1px solid var(--line); max-height: 340px; overflow: auto; }
.choice-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.choice-row:last-child { border-bottom: 0; }
.wizard-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

.progress { width: 140px; height: 6px; overflow: hidden; background: #e8edf3; border-radius: 3px; }
.progress span { display: block; height: 100%; background: var(--blue); }
.rule-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.auth-overview { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); margin-bottom: 16px; background: #fff; border: 1px solid var(--line); }
.auth-overview > div { min-height: 104px; padding: 17px 19px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.auth-overview > div:last-child { border-right: 0; }
.auth-overview span, .auth-overview small { color: var(--muted); font-size: 11px; }
.auth-overview strong { margin: 7px 0 5px; font-size: 20px; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 5px; min-width: 270px; }
.auth-message { max-width: 240px; color: var(--red); white-space: normal; }
.aweme-list { border: 1px solid var(--line); }
.aweme-row { display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 11px; align-items: center; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.aweme-row:last-child { border-bottom: 0; }
.aweme-avatar { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; color: var(--muted); background: var(--soft); }
.aweme-avatar img { width: 100%; height: 100%; object-fit: cover; }
.switch { position: relative; width: 38px; height: 21px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #cbd3df; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 17px; height: 17px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(17px); }

.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.setting-block { border: 1px solid var(--line); padding: 16px; }
.setting-block header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.setting-block header span { width: 35px; height: 35px; display: grid; place-items: center; background: var(--soft); border-radius: 5px; color: var(--blue); }
.setting-block h3 { font-size: 14px; margin: 0; }
.setting-block p { color: var(--muted); font-size: 11px; margin: 3px 0 0; }
.setting-block input { width: 100%; margin-bottom: 11px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, #f7faff 0, #eef3f8 100%); }
.login-panel { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(33,55,90,.12); padding: 30px; border-radius: 7px; }
.brand-login { min-width: 0; margin-bottom: 28px; }
.brand-login > span:last-child { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.login-form { display: grid; gap: 16px; }
.login-form input { width: 100%; height: 40px; }
.form-error { min-height: 16px; margin: -3px 0; color: var(--red); font-size: 12px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(20,29,45,.42); }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 7px; box-shadow: 0 24px 70px rgba(20,30,50,.25); }
.modal > header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); }
.modal h2 { margin: 0; font-size: 17px; }
.modal header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-body input, .modal-body select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 7px; }
.toast-root { position: fixed; z-index: 200; right: 20px; top: 74px; display: grid; gap: 9px; }
.toast { min-width: 280px; max-width: 380px; padding: 12px 14px; color: #fff; background: #263247; border-radius: 5px; box-shadow: 0 10px 26px rgba(25,35,55,.2); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { background: #b4232a; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

@media (max-width: 1100px) {
  :root { --sidebar: 76px; }
  .sidebar .nav-item span, .sidebar .nav-label, .sidebar-footer div:last-child, .nav-item b { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 0; }
  .sidebar-footer { justify-content: center; padding: 0; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .split, .settings-grid { grid-template-columns: 1fr; }
  .auth-overview { grid-template-columns: 1fr; }
  .auth-overview > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-overview > div:last-child { border-bottom: 0; }
}

@media (max-width: 720px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .brand { min-width: 0; }
  .brand small, .system-state, .top-actions .text-button { display: none; }
  .page { padding: 16px 12px 28px; }
  .page-head { align-items: flex-start; gap: 12px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 86px; }
  .flow-track { grid-template-columns: 1fr; }
  .flow-step { text-align: left; display: grid; grid-template-columns: 42px 1fr; border-right: 0; border-bottom: 1px solid var(--line); }
  .flow-step .step-icon { grid-row: 1 / span 2; margin: 0; }
  .wizard { grid-template-columns: 1fr; }
  .wizard-nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .wizard-nav button { min-width: 150px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .head-actions { flex-wrap: wrap; justify-content: flex-end; }
  .aweme-row { grid-template-columns: 40px minmax(0,1fr); }
  .aweme-row > div:last-child { grid-column: 2; }
  .filters { flex-wrap: wrap; }
  .search { width: 100%; }
}
