:root{
  --bg:#f5f7fb;
  --surface:#ffffff;
  --surface-soft:#f8fafc;
  --text:#172033;
  --muted:#6f7a90;
  --line:#e7ebf2;
  --primary:#315efb;
  --primary-dark:#2448d8;
  --primary-soft:#eef3ff;
  --success:#18a66a;
  --success-soft:#eaf8f1;
  --warning:#d68b11;
  --warning-soft:#fff7e8;
  --danger:#db4b55;
  --danger-soft:#fff0f1;
  --shadow:0 14px 35px rgba(24,38,73,.07);
  --radius:18px;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",Arial,sans-serif;color:var(--text);background:var(--bg)}
button,input,textarea,select{font:inherit}
button{cursor:pointer}
a{color:inherit}
.hidden{display:none!important}

/* Auth */
.auth-body{display:flex;align-items:center;justify-content:center;min-height:100vh;padding:32px;background:radial-gradient(circle at top left,#eef3ff 0,#f7f9fc 38%,#f4f6fa 100%)}
.auth-shell,.install-shell{width:min(440px,100%)}
.install-shell{width:min(780px,100%)}
.auth-brand{display:flex;align-items:center;gap:14px;margin:0 auto 20px;width:max-content}
.brand-mark{width:44px;height:44px;border-radius:14px;background:linear-gradient(145deg,#315efb,#6f8cff);display:grid;place-items:center;color:#fff;font-weight:800;box-shadow:0 10px 25px rgba(49,94,251,.28)}
.auth-brand strong{display:block;font-size:17px}.auth-brand span{display:block;margin-top:3px;font-size:12px;color:var(--muted)}
.auth-card{background:#fff;border:1px solid rgba(221,227,238,.9);border-radius:24px;padding:34px;box-shadow:0 24px 65px rgba(24,38,73,.10)}
.install-card{padding:34px 38px}
.auth-title h1{margin:0;font-size:28px}.auth-title p{margin:9px 0 24px;color:var(--muted);font-size:14px;line-height:1.7}
.auth-form,.form-stack{display:flex;flex-direction:column;gap:18px}
.auth-form label,.form-stack label,.form-grid label{display:flex;flex-direction:column;gap:8px}
.auth-form label span,.form-stack label>span,.form-grid label>span{font-size:13px;font-weight:700;color:#354158}
label small{font-size:12px;color:var(--muted);line-height:1.6}
input,textarea,select{width:100%;border:1px solid #dfe4ed;border-radius:12px;background:#fff;color:var(--text);padding:12px 14px;outline:none;transition:.2s;box-shadow:0 1px 0 rgba(16,24,40,.01)}
input:focus,textarea:focus,select:focus{border-color:#8ea7ff;box-shadow:0 0 0 4px rgba(49,94,251,.10)}
textarea{resize:vertical;line-height:1.65}
.auth-foot{text-align:center;color:#8791a4;font-size:12px;margin-top:18px}
.alert{border-radius:12px;padding:12px 14px;margin-bottom:18px;font-size:13px}.alert-error{background:var(--danger-soft);color:#b8343e;border:1px solid #ffd9dd}.alert-success{background:var(--success-soft);color:#16774f;border:1px solid #cceedd}
.section-caption{grid-column:1/-1;font-size:14px;font-weight:800;padding:4px 0 0;color:#202a3d}.install-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}.span-2{grid-column:1/-1}

/* Buttons */
.btn{border:1px solid #dfe4ed;background:#fff;color:#33405a;border-radius:11px;padding:10px 15px;font-weight:700;font-size:13px;transition:.18s;display:inline-flex;align-items:center;justify-content:center;gap:7px;text-decoration:none;white-space:nowrap}
.btn:hover{transform:translateY(-1px);border-color:#cdd5e3;box-shadow:0 6px 16px rgba(24,38,73,.08)}
.btn-primary{background:var(--primary);border-color:var(--primary);color:#fff}.btn-primary:hover{background:var(--primary-dark);border-color:var(--primary-dark)}
.btn-danger{color:#c43843;border-color:#f0c9cd;background:#fff7f7}.btn-sm{padding:8px 12px;font-size:12px}.btn-lg{padding:14px 18px;font-size:15px}.btn-block{width:100%}
.text-btn{border:0;background:transparent;color:var(--primary);font-size:13px;font-weight:700;padding:5px}

/* App layout */
.app-body{overflow-x:hidden}.app-shell{min-height:100vh}.sidebar{position:fixed;left:0;top:0;bottom:0;width:248px;background:#fff;border-right:1px solid var(--line);padding:20px 16px;display:flex;flex-direction:column;z-index:30}
.sidebar-brand{display:flex;align-items:center;gap:12px;padding:2px 8px 24px}.sidebar-brand .brand-mark{width:40px;height:40px;border-radius:13px}.brand-copy strong{display:block;font-size:15px}.brand-copy span{display:block;color:var(--muted);font-size:11px;margin-top:3px}
.sidebar-nav{display:flex;flex-direction:column;gap:5px}.nav-caption{padding:18px 12px 7px;color:#a0a8b7;font-size:11px;font-weight:800;letter-spacing:.08em}
.nav-item{width:100%;height:44px;border:0;background:transparent;border-radius:12px;display:flex;align-items:center;gap:11px;padding:0 12px;color:#69758a;font-size:14px;font-weight:700;text-align:left;transition:.18s}
.nav-item:hover{background:#f6f8fc;color:#26324a}.nav-item.active{background:var(--primary-soft);color:var(--primary)}.nav-icon{width:24px;height:24px;border-radius:8px;background:#f1f4f9;display:grid;place-items:center;font-size:11px;font-weight:900}.nav-item.active .nav-icon{background:#dfe8ff}.nav-item em{margin-left:auto;background:var(--danger);color:#fff;min-width:20px;height:20px;border-radius:10px;display:grid;place-items:center;font-style:normal;font-size:10px;padding:0 6px}
.sidebar-foot{margin-top:auto;border-top:1px solid var(--line);padding:16px 6px 0;display:flex;align-items:center;gap:10px}.user-chip{display:flex;align-items:center;gap:9px;min-width:0;flex:1}.user-chip>span{width:34px;height:34px;border-radius:11px;background:#eef3ff;color:var(--primary);display:grid;place-items:center;font-weight:800}.user-chip div{min-width:0}.user-chip strong{display:block;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.user-chip small{display:block;color:var(--muted);font-size:10px;margin-top:2px}.logout-link{font-size:11px;color:#9a6270;text-decoration:none}
.main-area{margin-left:248px;min-height:100vh}.topbar{height:84px;background:rgba(245,247,251,.92);backdrop-filter:blur(14px);position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;padding:0 34px;border-bottom:1px solid rgba(231,235,242,.85)}
.topbar h1{margin:0;font-size:22px}.topbar p{margin:4px 0 0;color:var(--muted);font-size:12px}.topbar-actions{display:flex;align-items:center;gap:9px;color:var(--muted);font-size:12px}.live-dot{width:8px;height:8px;border-radius:50%;background:var(--success);box-shadow:0 0 0 4px rgba(24,166,106,.12)}.menu-button{display:none;border:0;background:#fff;border-radius:10px;width:40px;height:40px}
.content-wrap{padding:30px 34px 45px;max-width:1700px;margin:0 auto}.page-section{display:none}.page-section.active{display:block}
.mobile-backdrop{display:none}

/* Cards / typography */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 4px 18px rgba(24,38,73,.025)}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:22px 22px 16px}.card-head h2{margin:0;font-size:17px}.card-head p{margin:6px 0 0;color:var(--muted);font-size:12px}
.page-intro{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:24px}.page-intro h2{margin:5px 0 8px;font-size:26px}.page-intro p{margin:0;color:var(--muted);font-size:14px}.eyebrow{font-size:11px;font-weight:800;color:var(--primary);letter-spacing:.08em}.intro-badge{background:#fff;border:1px solid var(--line);border-radius:14px;padding:11px 14px;color:#65728a;font-size:12px}
.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:18px}.stat-card{padding:20px 21px;position:relative;overflow:hidden}.stat-card .stat-label{color:var(--muted);font-size:12px;font-weight:700}.stat-card strong{display:block;font-size:29px;margin-top:10px;letter-spacing:-.03em}.stat-card small{display:block;color:#9099aa;font-size:11px;margin-top:6px}.stat-card .stat-dot{position:absolute;right:18px;top:18px;width:36px;height:36px;border-radius:12px;background:var(--primary-soft);display:grid;place-items:center;color:var(--primary);font-size:11px;font-weight:900}
.dashboard-grid{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(300px,.8fr);gap:18px}.two-column-layout{display:grid;grid-template-columns:minmax(0,1.25fr) minmax(300px,.75fr);gap:20px}.side-stack{display:flex;flex-direction:column;gap:18px}.form-card{padding:24px}.info-card,.tip-card{padding:22px}.info-card h3,.tip-card h3{margin:0 0 16px}.tip-card{background:linear-gradient(145deg,#fffaf0,#fff);border-color:#f2e1b9}.tip-card strong{display:block;font-size:14px}.tip-card p{margin:8px 0 0;color:#846c3d;line-height:1.7;font-size:12px}
.form-grid{display:grid;gap:16px}.form-grid.two{grid-template-columns:1fr 1fr}.form-stack b{color:var(--danger)}
.switch-row{display:flex!important;flex-direction:row!important;align-items:center;gap:12px!important;padding:12px 14px;background:var(--surface-soft);border:1px solid var(--line);border-radius:13px}.switch-row input{display:none}.switch{width:42px;height:24px;border-radius:12px;background:#cfd6e2;position:relative;transition:.2s;flex:0 0 auto}.switch:after{content:"";position:absolute;width:18px;height:18px;border-radius:50%;background:#fff;left:3px;top:3px;box-shadow:0 2px 7px rgba(0,0,0,.15);transition:.2s}.switch-row input:checked+.switch{background:var(--primary)}.switch-row input:checked+.switch:after{left:21px}.switch-row div{display:flex;flex-direction:column;gap:3px}.switch-row strong{font-size:13px}.switch-row small{font-size:11px;color:var(--muted)}
.steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:16px}.steps li{display:flex;gap:13px}.steps li>span{width:28px;height:28px;border-radius:10px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;font-size:11px;font-weight:800;flex:0 0 auto}.steps strong{display:block;font-size:13px}.steps p{margin:4px 0 0;color:var(--muted);font-size:12px;line-height:1.55}

/* Tables */
.table-card{overflow:hidden}.table-wrap{overflow:auto}.table-card .table-wrap{min-height:170px}table{width:100%;border-collapse:collapse}th{font-size:11px;color:#8b95a7;text-align:left;padding:12px 16px;background:#fbfcfe;border-bottom:1px solid var(--line);white-space:nowrap}td{padding:14px 16px;border-bottom:1px solid #edf0f5;font-size:12px;vertical-align:middle}tbody tr:last-child td{border-bottom:0}tbody tr:hover{background:#fbfcff}.wide-table{min-width:1050px}.product-table{min-width:1250px}
.table-main{max-width:310px}.table-main strong{display:block;font-size:13px;line-height:1.45}.table-main small{display:block;color:var(--muted);margin-top:4px;line-height:1.5}.muted{color:var(--muted)}
.status-badge{display:inline-flex;align-items:center;gap:6px;border-radius:999px;padding:5px 9px;font-size:10px;font-weight:800;white-space:nowrap}.status-badge:before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}.status-queued{background:#f0f3f8;color:#6e788b}.status-claimed,.status-running{background:#eef3ff;color:var(--primary)}.status-success{background:var(--success-soft);color:var(--success)}.status-failed{background:var(--danger-soft);color:var(--danger)}.status-canceled,.status-cancel_requested{background:var(--warning-soft);color:var(--warning)}
.progress-line{width:150px}.progress-top{display:flex;justify-content:space-between;gap:10px;color:var(--muted);font-size:10px;margin-bottom:6px}.progress-bar{height:6px;border-radius:3px;background:#edf0f5;overflow:hidden}.progress-bar span{display:block;height:100%;background:linear-gradient(90deg,#315efb,#7b94ff);border-radius:3px}.progress-count{margin-top:5px;font-size:10px;color:#8a94a7}
.table-actions{display:flex;gap:6px;white-space:nowrap}.icon-btn{border:1px solid var(--line);background:#fff;border-radius:9px;padding:7px 9px;font-size:11px;color:#58657a}.icon-btn:hover{border-color:#bfc9db;color:var(--primary)}.icon-btn.danger{color:var(--danger)}
.toolbar{padding:14px 16px;margin-bottom:15px;display:flex;align-items:center;justify-content:space-between;gap:14px}.filter-row,.toolbar-actions{display:flex;align-items:center;gap:9px}.filter-row input{width:240px}.filter-row select{width:150px}.product-toolbar .filter-row input:first-child{width:300px}.product-toolbar .filter-row input:nth-child(2){width:150px}
.pagination{display:flex;align-items:center;justify-content:flex-end;gap:6px;padding:14px 16px;border-top:1px solid var(--line)}.pagination button{border:1px solid var(--line);background:#fff;border-radius:8px;min-width:32px;height:32px;color:#68748a}.pagination button.active{background:var(--primary);color:#fff;border-color:var(--primary)}.pagination span{color:var(--muted);font-size:11px;margin-right:auto}
.empty-row td{text-align:center;color:var(--muted);padding:38px}
.product-cell{display:flex;align-items:center;gap:12px;max-width:370px}.product-image{width:52px;height:52px;border-radius:10px;background:#f0f2f6;object-fit:cover;flex:0 0 auto}.product-cell strong{font-size:12px;line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.product-cell a{color:inherit;text-decoration:none}.product-cell a:hover{color:var(--primary)}
.mark-badge{display:inline-flex;border-radius:999px;padding:5px 9px;font-size:10px;font-weight:800}.mark-unmarked{background:#f0f3f7;color:#778297}.mark-valid{background:var(--success-soft);color:var(--success)}.mark-invalid{background:var(--danger-soft);color:var(--danger)}.mark-follow_up{background:var(--warning-soft);color:var(--warning)}.mark-duplicate{background:#f2edff;color:#7551c9}
.selection-bar{display:none;background:#1f2a44;color:#fff;border-radius:14px;padding:10px 14px;margin-bottom:12px;align-items:center;gap:8px}.selection-bar.show{display:flex}.selection-bar span{margin-right:auto;font-size:12px}.selection-bar button{border:1px solid rgba(255,255,255,.18);background:rgba(255,255,255,.08);color:#fff;border-radius:8px;padding:7px 10px;font-size:11px}

/* Agents / integrations */
.agent-list{padding:0 20px 18px;display:flex;flex-direction:column;gap:10px}.agent-list.compact{min-height:180px}.agent-row{display:flex;align-items:center;gap:12px;padding:11px 0;border-bottom:1px solid #edf0f4}.agent-row:last-child{border-bottom:0}.agent-avatar{width:38px;height:38px;border-radius:12px;background:#f0f4ff;color:var(--primary);display:grid;place-items:center;font-size:11px;font-weight:900}.agent-row .grow{flex:1;min-width:0}.agent-row strong{display:block;font-size:12px}.agent-row small{display:block;color:var(--muted);font-size:10px;margin-top:4px}.online-pill{display:inline-flex;align-items:center;gap:5px;color:var(--success);font-size:10px;font-weight:800}.online-pill.offline{color:#9aa3b3}.online-pill:before{content:"";width:7px;height:7px;border-radius:50%;background:currentColor}
.integration-grid,.agent-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}.integration-card,.agent-card{padding:20px}.integration-top,.agent-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.integration-icon,.agent-card-icon{width:42px;height:42px;border-radius:13px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;font-weight:900}.integration-card h3,.agent-card h3{margin:16px 0 5px;font-size:15px}.integration-card p,.agent-card p{margin:0;color:var(--muted);font-size:11px;line-height:1.6}.integration-meta,.agent-meta{margin:16px 0;display:grid;gap:9px}.meta-line{display:flex;justify-content:space-between;gap:15px;font-size:11px}.meta-line span{color:var(--muted)}.meta-line strong{font-weight:700;max-width:65%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.card-actions{display:flex;gap:8px;border-top:1px solid var(--line);padding-top:14px}.card-actions .btn{flex:1}
.empty-state{text-align:center;padding:54px 24px}.empty-state h3{margin:14px 0 7px}.empty-state p{margin:0 0 18px;color:var(--muted);font-size:12px}.empty-icon{width:50px;height:50px;border-radius:16px;background:var(--primary-soft);color:var(--primary);display:grid;place-items:center;margin:0 auto;font-weight:900}
.setup-guide{margin-top:18px;padding:20px;display:flex;align-items:center;justify-content:space-between;gap:20px}.setup-guide h3{margin:0;font-size:15px}.setup-guide p{margin:6px 0 0;color:var(--muted);font-size:11px}.setup-codes{display:flex;align-items:center;gap:10px;color:#8b95a7}.setup-codes code{background:#f5f7fb;border:1px solid var(--line);border-radius:9px;padding:8px 10px;color:#38445c}
.settings-grid{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(300px,.7fr);gap:18px}

/* Modals */
.modal{position:fixed;inset:0;background:rgba(18,27,45,.46);display:none;align-items:center;justify-content:center;padding:24px;z-index:100;backdrop-filter:blur(5px)}.modal.show{display:flex}.modal-panel{width:min(560px,100%);max-height:90vh;overflow:auto;background:#fff;border-radius:22px;padding:26px;box-shadow:0 28px 75px rgba(16,24,40,.24);position:relative}.modal-wide{width:min(850px,100%)}.modal-close{position:absolute;right:16px;top:14px;width:34px;height:34px;border:0;background:#f3f5f9;border-radius:10px;color:#69758a;font-size:20px}.modal-head{padding-right:44px;margin-bottom:20px}.modal-head h2{margin:0;font-size:21px}.modal-head p{margin:7px 0 0;color:var(--muted);font-size:12px}.modal-actions{display:flex;justify-content:flex-end;gap:9px}.credential-box{margin-top:18px;padding:16px;border:1px solid #cdd9ff;background:#f4f7ff;border-radius:14px}.credential-box strong{display:block;font-size:13px}.credential-box code{display:block;margin:10px 0;padding:11px;background:#fff;border:1px solid #dfe7ff;border-radius:9px;word-break:break-all;font-size:11px}.credential-box p{font-size:11px;line-height:1.6;color:#5f6f90}.detail-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin:16px 0}.detail-box{padding:12px;background:#f8fafc;border:1px solid var(--line);border-radius:12px}.detail-box span{display:block;color:var(--muted);font-size:10px}.detail-box strong{display:block;margin-top:6px;font-size:12px;word-break:break-word}.log-list{display:flex;flex-direction:column;gap:8px;max-height:330px;overflow:auto}.log-item{border-left:3px solid #d8dee9;background:#f8fafc;border-radius:0 10px 10px 0;padding:10px 12px}.log-item.success{border-color:var(--success)}.log-item.error{border-color:var(--danger)}.log-item.warning{border-color:var(--warning)}.log-item strong{display:block;font-size:11px}.log-item small{display:block;color:var(--muted);font-size:10px;margin-top:4px}.section-title{margin:22px 0 10px;font-size:14px}

/* Toast */
.toast-container{position:fixed;right:24px;top:24px;z-index:200;display:flex;flex-direction:column;gap:10px}.toast{min-width:260px;max-width:420px;background:#202a3d;color:#fff;border-radius:12px;padding:12px 14px;box-shadow:var(--shadow);font-size:12px;animation:toastIn .2s ease}.toast.success{background:#167c53}.toast.error{background:#b63a45}.toast.warning{background:#9d6a12}@keyframes toastIn{from{transform:translateY(-8px);opacity:0}to{transform:translateY(0);opacity:1}}

@media(max-width:1180px){.stats-grid{grid-template-columns:repeat(2,1fr)}.dashboard-grid,.two-column-layout,.settings-grid{grid-template-columns:1fr}.integration-grid,.agent-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:820px){.sidebar{transform:translateX(-100%);transition:.22s}.sidebar.open{transform:translateX(0)}.mobile-backdrop.show{display:block;position:fixed;inset:0;background:rgba(15,23,42,.35);z-index:25}.main-area{margin-left:0}.menu-button{display:grid;place-items:center}.topbar{height:74px;padding:0 16px;justify-content:flex-start;gap:12px}.topbar-actions{margin-left:auto}.topbar-actions #serverClock,.topbar-actions .live-dot{display:none}.content-wrap{padding:20px 16px 35px}.toolbar{align-items:stretch;flex-direction:column}.filter-row{flex-wrap:wrap}.filter-row input,.filter-row select,.product-toolbar .filter-row input:first-child,.product-toolbar .filter-row input:nth-child(2){width:100%}.toolbar-actions{justify-content:flex-end}.page-intro{align-items:flex-start;flex-direction:column}.intro-badge{display:none}.integration-grid,.agent-grid{grid-template-columns:1fr}.setup-guide{align-items:flex-start;flex-direction:column}.setup-codes{flex-wrap:wrap}.detail-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:560px){.auth-body{padding:18px}.auth-card,.install-card{padding:24px}.install-grid,.form-grid.two{grid-template-columns:1fr}.span-2{grid-column:auto}.stats-grid{grid-template-columns:1fr 1fr;gap:10px}.stat-card{padding:16px}.stat-card strong{font-size:24px}.topbar-actions .btn{display:none}.page-intro h2{font-size:22px}.selection-bar{overflow:auto}.modal{padding:10px}.modal-panel{padding:22px 18px}.detail-grid{grid-template-columns:1fr 1fr}.toast-container{right:12px;left:12px;top:12px}.toast{min-width:0;max-width:none}}
