:root{
  --bg:#f4f5f7;--surface:#fff;--surface-2:#f8f9fb;--ink:#1d2433;--text:#475162;--muted:#7d8796;--faint:#a3abb7;
  --line:#e4e7ec;--line-soft:#eef0f3;--field:#d8dde4;
  --brand:#ffd94a;--brand-hover:#ffd11f;--brand-soft:#fff6cf;--brand-ink:#3d3209;--brand-deep:#9a7400;
  --green:#22966a;--green-soft:#e5f5ee;--green-ink:#17734f;--red:#d24a4d;--red-soft:#fdeeee;--red-ink:#a8383a;
  --amber:#c08512;--amber-soft:#fff3d9;--amber-ink:#875c00;--blue:#3d74d6;--blue-soft:#e9f0fc;--blue-ink:#2c5bb0;
  --radius:12px;--shadow:0 1px 2px rgba(16,24,40,.04),0 1px 3px rgba(16,24,40,.05);--shadow-lg:0 16px 40px rgba(16,24,40,.18);--aside:228px;
  font-family:"Segoe UI","Microsoft YaHei UI","Microsoft YaHei","PingFang SC",system-ui,sans-serif;color:var(--ink);background:var(--bg);font-size:14px;line-height:1.55
}
*{box-sizing:border-box}[hidden]{display:none!important}
body{margin:0;-webkit-font-smoothing:antialiased}
h1,h2,h3,h4,p{margin:0}
h1{font-size:17px}h2{font-size:24px;font-weight:700;letter-spacing:-.2px}h3{font-size:16px;font-weight:650}h4{font-size:14px;font-weight:650}
button,input,textarea,select{font:inherit;color:inherit}
a{color:var(--blue-ink);text-decoration:none}a:hover{text-decoration:underline}
:focus-visible{outline:2px solid #e2b300;outline-offset:2px}
.muted{color:var(--muted);font-size:13px}
.i{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.i.fill{fill:currentColor;stroke:none}

/* Buttons */
button{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:38px;padding:0 16px;border:1px solid var(--field);border-radius:9px;background:#fff;color:var(--ink);font-weight:550;white-space:nowrap;cursor:pointer;transition:background .15s,border-color .15s,color .15s}
button:hover:not(:disabled){background:#f6f7f9;border-color:#c6cdd6}
button:disabled{opacity:.45;cursor:not-allowed}
button .i{width:16px;height:16px}
.primary{background:var(--brand);border-color:#f0c93a;color:var(--brand-ink);box-shadow:0 1px 2px rgba(180,140,0,.18)}
.primary:hover:not(:disabled){background:var(--brand-hover);border-color:#e8bf22}
.ghost{background:transparent;border-color:transparent;color:var(--text)}
.ghost:hover:not(:disabled){background:#eceef2;border-color:transparent;color:var(--ink)}
.stop{color:#b23a3d;border-color:#eccacb}.stop:hover:not(:disabled){background:var(--red-soft);border-color:#e4b6b8}
.small{height:32px;padding:0 12px;font-size:13px;border-radius:8px}
.large{height:44px;font-size:15px}
.danger-text{color:#b8494c}.danger-text:hover:not(:disabled){background:var(--red-soft);color:var(--red-ink)}
.icon-button{width:32px;height:32px;padding:0;border:0;background:none;color:var(--muted)}
.icon-button:hover:not(:disabled){background:#eceef2;color:var(--ink)}

/* Form controls */
input:not([type=checkbox]):not([type=radio]),textarea,select{width:100%;min-width:0;border:1px solid var(--field);border-radius:8px;background:#fff;padding:8px 12px;font-size:14px;font-weight:400;outline:none;transition:border-color .15s,box-shadow .15s}
input:not([type=checkbox]):not([type=radio]),select{height:38px}
textarea{resize:vertical;line-height:1.6;min-height:92px}
input::placeholder,textarea::placeholder{color:#a9b0bb}
input:hover:not(:focus),textarea:hover:not(:focus),select:hover:not(:focus){border-color:#c6cdd6}
input:focus,textarea:focus,select:focus{border-color:#e3b800;box-shadow:0 0 0 3px rgba(255,217,74,.32)}
select{appearance:none;cursor:pointer;padding-right:34px;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237d8796' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 11px center}
input[type=checkbox]{accent-color:#d6a900;width:16px;height:16px;margin:0;cursor:pointer}
input[type=checkbox].switch{appearance:none;-webkit-appearance:none;position:relative;flex:none;width:38px;height:22px;border-radius:999px;background:#d3d8df;transition:background .2s;cursor:pointer}
input[type=checkbox].switch::after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.22);transition:transform .2s}
input[type=checkbox].switch:checked{background:var(--green)}
input[type=checkbox].switch:checked::after{transform:translateX(16px)}
.field{display:grid;gap:6px;font-size:13px;font-weight:600;color:var(--ink);min-width:0}
.field small{font-size:12px;font-weight:400;color:var(--faint)}
.field-label{display:block;font-size:13px;font-weight:600;margin-bottom:8px}
.field-status{display:block;min-height:20px;font-size:12px;font-weight:400;color:var(--muted);line-height:1.6}
.field-status.ok{color:var(--green-ink)}.field-status.warn{color:var(--amber-ink)}.field-status.error{color:var(--red-ink)}
.tag{display:inline-block;margin-left:6px;padding:0 6px;border-radius:4px;background:#eff1f4;color:var(--muted);font-size:11px;font-weight:500;vertical-align:1px}
.tag.required{background:var(--red-soft);color:var(--red-ink)}
.check{display:inline-flex;align-items:center;gap:8px;font-size:13px;cursor:pointer}

/* Login */
.login{min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(1200px 500px at 15% 0%,#fff6cf 0%,rgba(255,246,207,0) 60%),var(--bg)}
.login-shell{display:grid;grid-template-columns:minmax(0,1fr) 420px;gap:56px;align-items:center;width:min(980px,100%)}
.login-intro h2{font-size:30px;line-height:1.35;margin:34px 0 22px;letter-spacing:-.4px}
.login-points{list-style:none;margin:0;padding:0;display:grid;gap:12px;color:var(--text);font-size:15px}
.login-points li{display:flex;align-items:center;gap:12px}
.login-points span{display:grid;place-items:center;width:26px;height:26px;border-radius:50%;background:var(--brand);color:var(--brand-ink);font-size:13px;font-weight:700}
.login-card{padding:34px;display:grid;gap:16px}
.login-card .primary{width:100%}
#login-error{min-height:20px;color:var(--red-ink);font-size:13px}
.brand{display:flex;align-items:center;gap:10px}
.brand p{font-size:12px;color:var(--muted)}
.logo{display:grid;place-items:center;width:38px;height:38px;border-radius:11px;background:var(--brand);font-size:21px;font-weight:800;color:var(--brand-ink);box-shadow:inset 0 -2px 0 rgba(0,0,0,.06)}

/* Shell */
aside{position:fixed;inset:0 auto 0 0;width:var(--aside);background:#fff;border-right:1px solid var(--line);padding:18px 12px;display:flex;flex-direction:column;z-index:20}
aside .brand{padding:4px 8px 22px}
nav{display:grid;gap:2px}
nav button{justify-content:flex-start;gap:10px;width:100%;height:auto;padding:10px 12px;border:0;border-radius:9px;background:none;color:var(--text);font-weight:500}
nav button:hover:not(:disabled){background:#f2f3f6;color:var(--ink)}
nav button.active{background:var(--brand-soft);color:var(--brand-ink);font-weight:650}
nav button.active .i{color:var(--brand-deep)}
.nav-count{margin-left:auto;min-width:24px;padding:0 7px;border-radius:999px;background:#eff1f4;color:var(--muted);font-size:12px;font-style:normal;text-align:center}
.nav-count:empty{display:none}
nav button.active .nav-count{background:#fff;color:var(--brand-ink)}
.aside-bottom{margin-top:auto;border-top:1px solid var(--line);padding:14px 4px 0;display:grid;gap:8px}
.connection{display:flex;align-items:center;gap:8px;padding:0 8px;font-size:12px;color:var(--muted)}
.connection::before{content:"";width:8px;height:8px;border-radius:50%;background:#b8bec8;flex:none}
.connection.online::before{background:var(--green);box-shadow:0 0 0 3px var(--green-soft)}
.connection.offline::before{background:var(--amber);box-shadow:0 0 0 3px var(--amber-soft)}
.aside-bottom .ghost{justify-content:flex-start;color:var(--muted)}
.workspace-main{margin-left:var(--aside);min-height:100vh}
header{position:sticky;top:0;z-index:15;display:flex;align-items:center;gap:12px;height:64px;padding:0 32px;background:rgba(255,255,255,.92);backdrop-filter:blur(8px);border-bottom:1px solid var(--line)}
header .actions{margin-left:auto;display:flex;gap:10px}
.badge{display:inline-flex;align-items:center;gap:8px;height:30px;padding:0 12px;border-radius:999px;background:#eff1f4;color:var(--text);font-size:13px;font-weight:600;white-space:nowrap}
.badge::before{content:"";width:8px;height:8px;border-radius:50%;background:#a9b1bc}
.badge.running{background:var(--green-soft);color:var(--green-ink)}.badge.running::before{background:var(--green);animation:pulse 1.8s infinite}
.badge.busy{background:var(--amber-soft);color:var(--amber-ink)}.badge.busy::before{background:var(--amber)}
.badge.warn{background:var(--amber-soft);color:var(--amber-ink)}.badge.warn::before{background:var(--amber);animation:none}
@keyframes pulse{0%{box-shadow:0 0 0 0 rgba(34,150,106,.45)}70%{box-shadow:0 0 0 7px rgba(34,150,106,0)}100%{box-shadow:0 0 0 0 rgba(34,150,106,0)}}
.expiry{font-size:12px;color:var(--muted)}
.expiry.warn{color:var(--amber-ink);font-weight:600}
main{max-width:1400px;margin:0 auto;padding:28px 32px 120px}
main>section{animation:fade .18s ease}
@keyframes fade{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:18px}
.page-head p{margin-top:6px}
.head-actions{display:flex;align-items:center;gap:12px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:20px;margin-bottom:16px;box-shadow:var(--shadow)}
.grid{display:grid;gap:14px;margin-bottom:16px}.grid .card{margin-bottom:0}
.two{grid-template-columns:repeat(2,minmax(0,1fr))}
.title-row{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap}
.notice{background:var(--amber-soft);border:1px solid #f1dfae;border-radius:9px;padding:10px 14px;color:var(--amber-ink);font-size:13px}
.pager{display:flex;align-items:center;justify-content:center;gap:12px;margin:14px 0}
.pager span{color:var(--muted);font-size:13px}
.dirty-text{font-size:13px;color:var(--amber-ink);font-weight:600}
.dirty-text:empty{display:none}
.chip{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 10px;border-radius:999px;background:#eff1f4;color:var(--text);font-size:12px;font-weight:500}
.chip.ok{background:var(--green-soft);color:var(--green-ink)}.chip.warn{background:var(--amber-soft);color:var(--amber-ink)}

/* Overview */
.readiness{display:grid;grid-template-columns:minmax(200px,270px) minmax(0,1fr);gap:20px;align-items:center;border-left:4px solid #d3d8df}
.readiness.ready{border-left-color:var(--brand)}.readiness.blocked{border-left-color:var(--red)}.readiness.running{border-left-color:var(--green)}.readiness.paused{border-left-color:var(--amber)}
.readiness-head p{margin-top:4px}
.checklist{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.check-item{display:flex;align-items:flex-start;justify-content:flex-start;gap:10px;height:auto;min-width:0;padding:11px 12px;border:1px solid var(--line);border-radius:10px;background:#fff;text-align:left;font-weight:400;white-space:normal}
.check-item:hover:not(:disabled){background:var(--surface-2);border-color:#c9d0d8}
.check-item[disabled]{opacity:1;cursor:default}
.check-icon{display:grid;place-items:center;width:24px;height:24px;border-radius:50%;flex:none;background:#eff1f4;color:var(--muted)}
.check-icon .i{width:15px;height:15px;stroke-width:2.2}
.check-item.ok .check-icon{background:var(--green-soft);color:var(--green)}
.check-item.warn .check-icon{background:var(--amber-soft);color:var(--amber)}
.check-item.error{border-color:#f1cfd0;background:#fffafa}.check-item.error .check-icon{background:var(--red-soft);color:var(--red)}
.check-item strong{display:block;font-size:13px}
.check-item small{display:block;margin-top:1px;font-size:12px;color:var(--muted);line-height:1.5}
.check-item.error small{color:var(--red-ink)}.check-item.warn small{color:var(--amber-ink)}
.channel{border-top:3px solid #d3d8df;position:relative}
.channel-mark{position:absolute;right:9px;bottom:5px;font:10px/1 ui-monospace,Consolas,monospace;font-style:normal;letter-spacing:.5px;color:var(--muted);opacity:.32;pointer-events:none;user-select:none}
.channel.running{border-top-color:var(--green)}.channel.busy,.channel.warn{border-top-color:var(--amber)}
.channel-top{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}
.channel-id{display:flex;align-items:center;gap:12px}
.channel-id small{display:block;font-size:12px;color:var(--muted)}
.mode{display:grid;place-items:center;width:36px;height:36px;border-radius:9px;background:#fff3cf;color:#8a6a00;font-weight:700}
.mode.c2{background:var(--blue-soft);color:var(--blue-ink)}
.status{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 9px;border-radius:999px;background:#eff1f4;color:var(--muted);font-size:12px;font-weight:600;white-space:nowrap}
.status::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.status.running,.status.ready{background:var(--green-soft);color:var(--green-ink)}
.status.busy,.status.warn,.status.pending{background:var(--amber-soft);color:var(--amber-ink)}
.status.invalid,.status.error{background:var(--red-soft);color:var(--red-ink)}
.channel-body{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;padding-top:12px;border-top:1px solid var(--line-soft)}
.number{font-size:30px;font-weight:700;line-height:1.1;letter-spacing:-.5px;font-variant-numeric:tabular-nums}
.number small{font-size:13px;font-weight:500;letter-spacing:0}
.channel-hint{max-width:56%;font-size:13px;color:var(--text);text-align:right}
.channel.warn .channel-hint{color:var(--amber-ink)}
.products-card>.muted{margin:4px 0 6px}
.count-chip{display:inline-block;margin-left:6px;padding:0 8px;border-radius:999px;background:#eff1f4;color:var(--muted);font-size:12px;font-weight:500;vertical-align:2px}
.count-chip:empty{display:none}
.toolbar-inline{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.search{position:relative;display:block;width:300px;max-width:100%}
.search .i{position:absolute;left:11px;top:50%;transform:translateY(-50%);width:16px;height:16px;color:var(--faint);pointer-events:none}
.search input{padding-left:34px!important}
#product-channel{width:auto;min-width:120px}
.product{display:grid;grid-template-columns:60px minmax(0,1fr) auto;align-items:center;gap:14px;padding:14px 0;border-bottom:1px solid var(--line-soft)}
.product:last-child{border-bottom:0}
.thumb{display:grid;place-items:center;width:60px;height:60px;border-radius:9px;background:#f0f2f5;color:#b4bcc6;overflow:hidden}
.thumb img{display:block;width:100%;height:100%;object-fit:cover}
.thumb .i{width:22px;height:22px}
.product-info{min-width:0}
.product-title{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;color:var(--ink);font-size:14px;font-weight:600;line-height:1.5;overflow-wrap:anywhere}
.product-title:hover{color:var(--brand-deep);text-decoration:none}
.product-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:5px;font-size:12px;color:var(--faint)}
.pill{display:inline-block;max-width:220px;padding:0 8px;border-radius:6px;background:#eff1f4;color:var(--text);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pill.keyword{background:var(--brand-soft);color:#7a6100}.pill.c1{background:#fff3cf;color:#8a6a00}.pill.c2{background:var(--blue-soft);color:var(--blue-ink)}
.product-side{display:grid;justify-items:end;gap:8px}
.product-price{color:#e5482d;font-size:17px;font-weight:700;white-space:nowrap;font-variant-numeric:tabular-nums}
.product-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.product-actions a{display:inline-flex;align-items:center;height:30px;padding:0 10px;border:1px solid var(--field);border-radius:7px;color:var(--ink);font-size:12px;font-weight:550;text-decoration:none}
.product-actions a:hover{background:#f6f7f9}
.product-actions a.order{background:var(--brand);border-color:#f0c93a;color:var(--brand-ink)}
.product-actions button{height:30px;padding:0 10px;font-size:12px;border-radius:7px}
.empty{padding:36px 20px;text-align:center;color:var(--muted)}
.empty strong{display:block;color:var(--ink);font-size:15px;margin-bottom:4px}

/* Rules */
.example{display:flex;gap:10px;align-items:flex-start;margin:0 0 14px;padding:10px 14px;border-radius:10px;background:var(--brand-soft);border:1px solid #f3e3a3;color:#6b5600;font-size:13px}
.example b{flex:none;padding:0 6px;border-radius:4px;background:#fff;color:var(--brand-deep);font-size:12px}
.toolbar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:10px 14px}
.toolbar .sep{width:1px;height:20px;background:var(--line);margin:0 4px}
.rules-summary{margin-left:auto;margin-right:8px}
.rule{padding:0;transition:border-color .15s,box-shadow .15s}
.rule-head{display:flex;align-items:center;gap:12px;padding:10px 12px 10px 16px}
.switch-line{display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-size:13px;color:var(--text);white-space:nowrap}
.rule-summary{flex:1;min-width:0;justify-content:flex-start;align-items:baseline;gap:12px;height:auto;padding:6px 0;border:0;background:none;text-align:left;font-weight:400}
.rule-summary:hover:not(:disabled){background:none}
.rule-summary strong{flex:none;max-width:240px;overflow:hidden;text-overflow:ellipsis;font-size:15px;color:var(--ink)}
.rule-preview{min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:13px;color:var(--muted)}
.rule:not(.collapsed) .rule-preview{white-space:normal}
.rule-actions{display:flex;gap:2px}
.chevron .i{transition:transform .2s}
.rule:not(.collapsed) .chevron .i{transform:rotate(180deg)}
.rule-body{padding:16px 20px 20px;border-top:1px solid var(--line-soft)}
.rule.collapsed .rule-body{display:none}
.rule.paused .rule-summary strong{opacity:.5}
.rule.invalid{border-color:#efc3c4}.rule.invalid .rule-preview{color:var(--red-ink)}
.rule.dirty{border-color:#f0ca36;box-shadow:0 0 0 3px rgba(255,217,74,.25)}
.rule-fields{display:grid;grid-template-columns:minmax(200px,1.2fr) minmax(260px,1.2fr) minmax(180px,.9fr);gap:18px;margin-bottom:16px}
.price{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:8px}
.price span{color:var(--faint);font-weight:400}
.secondary{padding:14px 16px;border:1px solid var(--line-soft);border-radius:10px;background:var(--surface-2)}
.secondary-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:12px}
.secondary-head p{margin-top:2px;font-size:12px}
.secondary-rows{display:grid;gap:8px}
.secondary-row{display:grid;grid-template-columns:minmax(140px,1.6fr) minmax(90px,1fr) minmax(90px,1fr) 32px;gap:8px;align-items:end}
.secondary-row label{display:grid;gap:4px;font-size:12px;color:var(--muted);min-width:0}
.secondary-row~.secondary-row .lbl{display:none}
.secondary-row [data-action=remove-secondary]{margin-bottom:3px}
.secondary-empty{padding:12px;border:1px dashed var(--field);border-radius:8px;background:#fff;color:var(--muted);font-size:13px;text-align:center}

/* Accounts */
.sync-guide .title-row{margin-bottom:14px}
.ext-status{display:flex;align-items:center;gap:8px}
.install-link{display:inline-flex;align-items:center;min-height:38px;margin:8px 0;padding:0 12px;border:1px solid #f0c93a;border-radius:8px;font-size:13px;font-weight:600}
.install-link:hover{background:var(--brand-hover);text-decoration:none}
.steps li.complete{background:var(--green-soft,#eaf6ef)}
.steps li.complete b{background:#198e65;color:white}
.steps{list-style:none;margin:0 0 14px;padding:0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.steps li{display:flex;gap:10px;align-items:flex-start;padding:12px;border-radius:10px;background:var(--surface-2);border:1px solid var(--line-soft)}
.steps b{display:grid;place-items:center;width:26px;height:26px;flex:none;border-radius:50%;background:var(--brand);color:var(--brand-ink);font-size:13px}
.steps strong{display:block;font-size:14px}
.steps small{display:block;font-size:12px;color:var(--muted);line-height:1.5}
.sync-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.account-summary{margin:0 0 10px}
.account-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(250px,100%),1fr));gap:12px}
.account{display:grid;grid-template-columns:minmax(0,1fr);min-width:0;gap:10px;margin:0;padding:16px;border-top:3px solid #d3d8df}
.account.none{background:var(--surface-2);box-shadow:none;border-top-color:var(--line)}
.account.none .account-name strong{color:var(--muted);font-weight:500}
.account.next{background:#fff;border-top-color:var(--brand);box-shadow:var(--shadow)}
.account-hint{font-size:12px;color:var(--muted);min-height:18px}
.account.invalid .account-hint{color:var(--red-ink)}
.account.ready{border-top-color:var(--green)}.account.pending{border-top-color:var(--amber)}.account.invalid{border-top-color:var(--red)}
.account-top{display:flex;align-items:center;gap:12px}
.avatar{display:grid;place-items:center;width:40px;height:40px;flex:none;border-radius:50%;background:#eff1f4;color:var(--muted);font-size:13px;font-weight:650}
.account.ready .avatar{background:var(--green-soft);color:var(--green-ink)}
.account-name{flex:1;min-width:0}
.account-name strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.account-updated{display:flex;flex-wrap:wrap;gap:4px 8px;font-size:12px;color:var(--muted)}
.account button{width:100%}

/* Settings */
.settings-stack{display:grid;gap:16px}
.settings-section{display:grid;grid-template-columns:230px minmax(0,1fr);gap:28px;margin:0;padding:22px 24px}
.section-intro p{margin-top:4px}
.section-body{display:grid;gap:18px;min-width:0;align-content:start}
.minutes-row{display:flex;flex-wrap:wrap;align-items:center;gap:12px}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip-button{height:32px;padding:0 13px;border-radius:999px;font-size:13px;font-weight:500;color:var(--text)}
.chip-button.active{background:var(--brand-soft);border-color:#efcb45;color:var(--brand-ink);font-weight:650}
.number-unit{display:inline-flex;align-items:center;gap:8px;font-size:13px;color:var(--muted)}
.number-unit input{width:96px!important}
#minutes-field.muted-field .chips,#minutes-field.muted-field .number-unit{opacity:.5}
.switch-groups{display:grid;gap:18px}
.switch-group h4{font-size:13px;color:var(--muted);margin-bottom:10px}
.switch-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px}
.switch-card{display:flex;align-items:flex-start;gap:12px;padding:13px 14px;border:1px solid var(--line);border-radius:10px;background:#fff;cursor:pointer;transition:border-color .15s,background .15s}
.switch-card:hover{border-color:#cbd1d9}
.switch-card:has(input:checked){border-color:#b9e0cd;background:#f4fbf7}
.switch-card strong{display:block;font-size:14px}
.switch-card small{display:block;margin-top:2px;font-size:12px;color:var(--muted);line-height:1.6}
.word-lists{grid-template-columns:repeat(3,minmax(0,1fr))}
.notify-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.segmented{display:inline-flex;justify-self:start;align-self:start;gap:2px;padding:3px;border-radius:10px;background:#eef0f3}
.segmented label{position:relative;cursor:pointer}
.segmented input{position:absolute;opacity:0;width:1px;height:1px;margin:0}
.segmented span{display:block;padding:6px 16px;border-radius:8px;font-size:13px;color:var(--text)}
.segmented input:checked+span{background:#fff;color:var(--ink);font-weight:650;box-shadow:0 1px 3px rgba(16,24,40,.12)}
.segmented input:focus-visible+span{outline:2px solid #e2b300}

/* Logs */
.logs-card{padding:0;overflow:hidden}
.log-toolbar{display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:14px 18px;border-bottom:1px solid var(--line-soft)}
.log-toolbar select{width:auto;min-width:130px}
#log-note{margin-left:auto}
.log-entry{display:grid;grid-template-columns:150px 62px minmax(0,1fr);gap:12px;padding:9px 18px;border-bottom:1px solid #f4f5f7;font-size:13px}
.log-entry:last-child{border-bottom:0}
.log-entry time{color:var(--faint);font-variant-numeric:tabular-nums}
.log-channel{align-self:start;padding:0 6px;border-radius:5px;background:#eff1f4;color:var(--muted);font-size:12px;text-align:center}
.log-channel.c1{background:#fff3cf;color:#8a6a00}.log-channel.c2{background:var(--blue-soft);color:var(--blue-ink)}
.log-message{overflow-wrap:anywhere;color:var(--text)}
.log-entry.error{background:#fff8f8}.log-entry.error .log-message{color:var(--red-ink)}
.log-entry.ok .log-message{color:var(--green-ink)}

/* Save bar & toast */
#savebar{position:fixed;left:calc(var(--aside) + 24px);right:24px;bottom:20px;z-index:30;display:flex;align-items:center;justify-content:space-between;gap:16px;max-width:820px;margin:0 auto;padding:10px 12px 10px 20px;border-radius:12px;background:#1f2633;color:#fff;box-shadow:var(--shadow-lg);animation:rise .2s ease}
#savebar strong{display:block;font-size:14px}
#savebar small{display:block;font-size:12px;color:#b6bfcc}
.savebar-actions{display:flex;gap:8px}
#savebar .ghost{color:#dde2e9}#savebar .ghost:hover:not(:disabled){background:rgba(255,255,255,.12);color:#fff}
@keyframes rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
#message{position:fixed;top:76px;left:50%;transform:translateX(-50%);z-index:40;max-width:calc(100% - 32px);padding:11px 18px;border-radius:10px;background:#1f2633;color:#fff;font-size:13px;box-shadow:var(--shadow-lg);animation:rise .2s ease}
#message.error{background:#a8383a}

/* Responsive */
@media(max-width:1180px){
  .checklist{grid-template-columns:repeat(2,minmax(0,1fr))}
  .readiness{grid-template-columns:1fr}
  .settings-section{grid-template-columns:1fr;gap:14px}
  .word-lists{grid-template-columns:1fr}
  .rule-fields{grid-template-columns:1fr 1fr}.rule-fields>label:last-child{grid-column:1/-1;max-width:380px}
  .steps{grid-template-columns:repeat(2,minmax(0,1fr))}
  .login-shell{grid-template-columns:1fr;gap:28px;max-width:460px}
  .login-intro h2{font-size:24px;margin:22px 0 14px}
}
@media(max-width:900px){
  :root{--aside:0px}
  aside{position:static;width:auto;padding:12px 14px;border-right:0;border-bottom:1px solid var(--line);flex-direction:row;flex-wrap:wrap;align-items:center;gap:8px}
  aside .brand{padding:0}
  nav{display:flex;order:3;width:100%;overflow-x:auto;gap:4px}
  nav button{width:auto;white-space:nowrap;padding:8px 10px}
  .aside-bottom{margin:0 0 0 auto;padding:0;border:0;display:flex;align-items:center}
  .connection{display:none}
  .workspace-main{margin:0}
  header{position:static;height:auto;padding:10px 14px;flex-wrap:wrap}
  #expiry{order:3;width:100%}
  main{padding:18px 14px 120px}
  .page-head{flex-direction:column;align-items:stretch}
  .two{grid-template-columns:1fr}
  .channel-hint{max-width:none}
  .rule-fields{grid-template-columns:1fr}.rule-fields>label:last-child{max-width:none}
  .rule-head{flex-wrap:wrap;gap:8px}
  .rule-summary{order:4;flex-basis:100%;max-width:100%;flex-direction:column;align-items:flex-start;gap:0;white-space:normal}
  .rule-summary strong{max-width:100%}
  .rule .rule-preview{white-space:normal}
  .rule-actions{margin-left:auto}
  .rules-summary{margin-left:0;flex-basis:100%}
  .secondary-row{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 32px;padding-bottom:10px;border-bottom:1px solid var(--line)}
  .secondary-row label:first-child{grid-column:1/-1}
  .secondary-row .lbl{display:none}
  .secondary-head{flex-wrap:wrap}
  .product{grid-template-columns:48px minmax(0,1fr);gap:10px}
  .thumb{width:48px;height:48px}
  .product-side{grid-column:1/-1;grid-template-columns:auto 1fr;align-items:center;justify-items:stretch}
  .product-price{justify-self:start}
  .search{width:100%}
  .toolbar-inline{width:100%}
  .log-entry{grid-template-columns:1fr auto;gap:2px 10px}
  .log-message{grid-column:1/-1}
  #savebar{left:12px;right:12px;bottom:12px;flex-direction:column;align-items:stretch}
  .savebar-actions{justify-content:flex-end}
  #message{top:auto;bottom:16px}
}
@media(max-width:560px){
  .checklist,.steps{grid-template-columns:1fr}
  h2{font-size:21px}
  .card{padding:16px}
  .settings-section{padding:16px}
  header .actions{width:100%}
  header .actions button{flex:1}
  .login-card{padding:22px}
}
/* Local configuration import: a keyboard-accessible dialog on desktop and mobile. */
#config-import-dialog{width:min(620px,calc(100vw - 28px));max-height:calc(100dvh - 28px);margin:auto;padding:24px;border:1px solid #dce2eb;border-radius:14px;color:#152a43;background:#fff;box-shadow:0 20px 70px #152a4333;overflow:auto;box-sizing:border-box}
#config-import-dialog::backdrop{background:#152a4370}
#config-import-dialog .field{margin:16px 0}
#config-import-dialog input[type=file]{max-width:100%;min-width:0;font:inherit}
#config-import-dialog .head-actions{display:flex;flex-wrap:wrap;gap:10px;justify-content:flex-end}
#config-import-dialog .import-summary{padding:14px;background:#f5f7fa;border-radius:8px;white-space:pre-line;overflow-wrap:anywhere;line-height:1.8}
#config-import-dialog .import-undo{margin-top:22px;border-top:1px solid #dce2eb;padding-top:10px}
#config-import-dialog #config-import-error{color:#c22c3c;min-height:1.4em;overflow-wrap:anywhere}
@media(max-width:600px){#config-import-dialog{padding:18px}#config-import-dialog h2{font-size:20px}#config-import-dialog .head-actions>button{flex:1}}
/* Manual Cookie paste: the same dialog treatment as configuration import. */
#cookie-dialog{width:min(560px,calc(100vw - 28px));max-height:calc(100dvh - 28px);margin:auto;padding:24px;border:1px solid #dce2eb;border-radius:14px;color:#152a43;background:#fff;box-shadow:0 20px 70px #152a4333;overflow:auto;box-sizing:border-box}
#cookie-dialog::backdrop{background:#152a4370}
#cookie-dialog .field{margin:16px 0}
#cookie-dialog textarea{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:13px;word-break:break-all;min-height:132px}
#cookie-dialog .head-actions{display:flex;flex-wrap:wrap;gap:10px;justify-content:flex-end}
#cookie-dialog #cookie-replace{margin:0}
#cookie-dialog #cookie-error{color:#c22c3c;min-height:1.4em;overflow-wrap:anywhere;margin:0 0 6px}
@media(max-width:600px){#cookie-dialog{padding:18px}#cookie-dialog h2{font-size:20px}#cookie-dialog .head-actions>button{flex:1}}

/* Account onboarding and one-click login flow */
.ext-bar{display:flex;flex-wrap:wrap;align-items:center;gap:10px 16px;padding:14px 18px}
.ext-bar-main{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;flex:1;min-width:240px}
.ext-bar .install-link{margin:0}
.ext-bar.complete{border-color:#cfe9dc}
.browser-login{font-size:13px;color:var(--text)}
.login-flow{padding:18px 20px;border-color:#efcb45;background:linear-gradient(180deg,#fffdf2,#fff 70%)}
.login-flow[data-phase=success]{border-color:#bfe3d2;background:linear-gradient(180deg,#f2faf6,#fff 70%)}
.login-flow[data-phase=failed]{border-color:#efc7c8;background:linear-gradient(180deg,#fff5f5,#fff 70%)}
.login-flow[data-phase=cancelled]{border-color:var(--line);background:var(--surface)}
.login-flow-head{display:flex;align-items:center;gap:14px}
.login-flow-text{flex:1;min-width:0}
.login-flow-text h3{font-size:16px;color:var(--ink)}
.login-flow-text p{margin-top:3px;color:var(--text)}
.login-badge{display:grid;place-items:center;width:40px;height:40px;flex:none;border-radius:50%}
.login-badge.busy{border:3px solid var(--brand-soft);border-top-color:var(--brand-deep);animation:spin .9s linear infinite}
.login-badge.ask{background:var(--brand-soft);color:var(--brand-deep);font-size:20px;font-weight:800}
.login-badge.ask:after{content:"?"}
.login-badge.ok{background:var(--green-soft)}
.login-badge.ok:after{content:"";width:14px;height:7px;border-left:3px solid var(--green);border-bottom:3px solid var(--green);transform:translateY(-2px) rotate(-45deg)}
.login-badge.error{background:var(--red-soft);color:var(--red);font-size:20px;font-weight:800}
.login-badge.error:after{content:"!"}
.login-badge.idle{background:var(--surface-2);border:1px solid var(--line)}
.login-badge.idle:after{content:"";width:12px;height:3px;border-radius:2px;background:var(--faint)}
@keyframes spin{to{transform:rotate(360deg)}}
.login-steps{display:flex;flex-wrap:wrap;gap:8px;margin:16px 0 0;padding:0;list-style:none}
.login-steps li{display:flex;align-items:center;gap:8px;flex:1;min-width:140px;padding:9px 12px;border-radius:9px;background:var(--surface-2);color:var(--muted);font-size:13px}
.login-steps .dot{width:16px;height:16px;flex:none;border:2px solid var(--field);border-radius:50%;background:#fff}
.login-steps li.current,.login-steps li.active{background:var(--brand-soft);color:var(--brand-ink);font-weight:600}
.login-steps li.current .dot{border-color:var(--brand-deep)}
.login-steps li.active .dot{border-color:var(--brand-deep);border-top-color:transparent;background:transparent;animation:spin .9s linear infinite}
.login-steps li.done{background:var(--green-soft);color:var(--green-ink)}
.login-steps li.done .dot{border-color:var(--green);background:var(--green)}
.login-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;margin-top:14px}
.account-updated time{display:inline-block;white-space:nowrap}
.account-actions{display:flex;gap:8px}
.account .account-actions button{width:auto;flex:1}
.account .account-actions .ghost{flex:0 0 auto}
.account-add{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:auto;min-height:150px;padding:16px;border:1.5px dashed var(--field);border-radius:var(--radius);background:transparent;color:var(--ink);font-weight:550;white-space:normal}
.account-add:hover:not(:disabled){border-color:#efcb45;background:var(--brand-soft)}
.account-add-icon{display:grid;place-items:center;width:38px;height:38px;border-radius:50%;background:var(--brand-soft);color:var(--brand-deep)}
.account-add:hover .account-add-icon{background:#fff}
.account-add small{font-size:12px;font-weight:400;color:var(--muted)}
.account-notice{margin-top:16px}
@media (max-width:640px){.login-steps li{min-width:100%}.login-actions button{flex:1}}
@media (prefers-reduced-motion:reduce){.login-badge.busy,.login-steps li.active .dot{animation:none}}

/* Account files are selected explicitly; no Cookie value is rendered in the import dialog. */
#view-accounts .page-head>.head-actions{flex-wrap:wrap}
#account-import-dialog{width:min(660px,calc(100vw - 28px));max-height:calc(100dvh - 28px);margin:auto;padding:24px;border:1px solid var(--line);border-radius:14px;color:var(--ink);background:var(--surface);box-shadow:var(--shadow-lg);overflow:auto;box-sizing:border-box}
#account-import-dialog::backdrop{background:#152a4370}
#account-import-dialog .head-actions{flex-wrap:wrap;justify-content:flex-end;gap:10px}
#account-import-dialog .file-pickers{justify-content:flex-start;margin:18px 0}
#account-import-dialog code{overflow-wrap:anywhere}
#account-import-summary{margin:12px 0}
#account-import-list{list-style:none;padding:0;margin:0 0 16px;max-height:300px;overflow:auto}
#account-import-list li{display:flex;justify-content:space-between;gap:14px;padding:10px 0;border-bottom:1px solid var(--line-soft);align-items:flex-start}
#account-import-list .file-name{min-width:0;overflow-wrap:anywhere;flex:1}
#account-import-list .file-result{max-width:62%;text-align:right;overflow-wrap:anywhere;color:var(--muted)}
#account-import-list .imported .file-result{color:var(--green-ink)}
#account-import-list .failed .file-result,#account-import-list .invalid .file-result{color:var(--red-ink)}
#account-import-error{min-height:1.4em;overflow-wrap:anywhere}
@media(max-width:600px){#account-import-dialog{padding:18px}#account-import-dialog h2{font-size:20px}#account-import-dialog .head-actions>button{flex:1}#account-import-list li{display:block}#account-import-list .file-result{display:block;text-align:left;max-width:100%;margin-top:4px}}
