:root {
  --ink: #171916;
  --muted: #777b72;
  --paper: #f3f4ef;
  --panel: #fffefb;
  --line: #e5e7df;
  --accent: #ff6534;
  --accent-soft: #fff0e8;
  --green: #238762;
  --green-soft: #e7f5ee;
  --blue: #4775df;
  --red: #bb4b42;
  --shadow: 0 14px 38px rgba(29, 33, 27, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: var(--paper); font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: #9b9e95; font-size: 10px; font-weight: 800; letter-spacing: .17em; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 12%, #fff2e9 0, transparent 28%), radial-gradient(circle at 85% 78%, #e6efe8 0, transparent 25%), #eeefe9; }
.login-card { width: min(390px, 100%); padding: 34px; background: rgba(255,255,252,.94); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: 0 30px 90px rgba(28,32,26,.14); }
.logo { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 22px; color: white; background: var(--accent); border-radius: 18px 18px 18px 5px; font-size: 24px; font-weight: 900; box-shadow: 0 12px 25px rgba(255,101,52,.24); }
.logo.small { width: 38px; height: 38px; margin: 0; border-radius: 12px 12px 12px 4px; font-size: 16px; }
.login-card h1 { margin: 0; font-size: 27px; }
.login-card > .muted { margin: 9px 0 23px; font-size: 12px; line-height: 1.6; }
label { color: var(--muted); font-size: 11px; }
input, select, textarea { width: 100%; color: var(--ink); background: #fafaf6; border: 1px solid var(--line); border-radius: 10px; outline: none; }
input, select { height: 40px; padding: 0 11px; }
textarea { padding: 12px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,101,52,.12); }
.login-card label { display: block; margin-top: 13px; }
.login-card label input { margin-top: 6px; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 11px; text-align: center; }
.button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 10px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.button.primary { color: white; background: var(--accent); }
.button.dark { color: white; background: #262923; }
.button.ghost { color: #555950; background: #f3f4ef; border: 1px solid #dfe2d9; }
.button.danger { color: var(--red); background: #fff0ed; border: 1px solid #f1c9c4; }
.button.wide { width: 100%; margin-top: 22px; }
.app { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 15px 18px; color: #eeefe9; background: #191b18; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 28px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; }
.brand span { margin-top: 3px; color: #777d72; font-size: 8px; letter-spacing: .12em; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav button { height: 43px; display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 8px; padding: 0 12px; color: #a9ada3; background: transparent; border: 0; border-radius: 10px; text-align: left; font-size: 12px; }
.sidebar nav button i { font-style: normal; font-size: 16px; text-align: center; }
.sidebar nav button b { min-width: 20px; padding: 2px 6px; color: #bbbfb4; background: #2e312c; border-radius: 8px; font-size: 8px; text-align: center; }
.sidebar nav button.active { color: white; background: #2b2e29; }
.sidebar nav button.active i { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: grid; gap: 14px; padding: 14px 9px 0; border-top: 1px solid #30332e; }
.connection { display: flex; align-items: center; gap: 8px; color: #959a90; font-size: 9px; }
.connection i { width: 7px; height: 7px; background: #e48a4e; border-radius: 50%; box-shadow: 0 0 0 4px rgba(228,138,78,.1); }
.connection i.online { background: #54c68c; box-shadow: 0 0 0 4px rgba(84,198,140,.1); }
.sidebar-foot button { justify-self: start; padding: 0; color: #73786e; background: transparent; border: 0; font-size: 9px; }
main { min-width: 0; padding: 27px 32px 90px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
header h1 { margin: 0; font-size: 27px; letter-spacing: -.04em; }
.header-actions { display: flex; gap: 8px; }
.runtime-bar { min-height: 66px; display: grid; grid-template-columns: 22px minmax(180px,.55fr) minmax(220px,1fr) auto; align-items: center; gap: 13px; margin-bottom: 16px; padding: 12px 15px; color: white; background: #262923; border-radius: 14px; box-shadow: var(--shadow); }
.runtime-bar strong, .runtime-bar span { display: block; }
.runtime-bar strong { font-size: 11px; }
.runtime-bar > div > span { margin-top: 4px; color: #9a9f94; font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spinner { width: 13px; height: 13px; border: 2px solid #666b61; border-top-color: var(--accent); border-radius: 50%; }
.runtime-bar.busy .spinner { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-box > span { margin: 0 0 5px; color: #d6d9d1; font-size: 8px; text-align: right; }
.progress-box > div { height: 4px; overflow: hidden; background: #464a43; border-radius: 5px; }
.progress-box i { width: 0; height: 100%; display: block; background: var(--accent); transition: width .25s; }
.page { display: none; }
.page.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.panel-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 19px; }
.panel-head span { display: block; margin-bottom: 5px; color: #a0a39a; font-size: 8px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head select { width: auto; min-width: 130px; height: 34px; font-size: 10px; }
.analysis-filter { margin-bottom: 13px; padding: 14px; }
.analysis-filter-grid { display: grid; grid-template-columns: repeat(6,minmax(100px,1fr)) auto; align-items: end; gap: 9px; }
.analysis-filter-grid label { min-width: 0; }
.analysis-filter-grid input, .analysis-filter-grid select { margin-top: 5px; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; margin-bottom: 13px; }
.metric { min-width: 0; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.metric span { display: block; color: var(--muted); font-size: 9px; }
.metric strong { display: block; margin: 11px 0 8px; font-size: 23px; letter-spacing: -.04em; }
.metric small { color: #9da097; font-size: 9px; }
.grid { display: grid; gap: 13px; margin-bottom: 13px; }
.grid.two { grid-template-columns: minmax(0,1.5fr) minmax(280px,.7fr); }
.chart-wrap { position: relative; height: 280px; padding: 0 12px 13px; }
.chart-wrap canvas { width: 100%; height: 100%; }
.tooltip { position: absolute; display: none; min-width: 150px; padding: 10px; color: white; background: rgba(31,34,29,.94); border-radius: 9px; pointer-events: none; font-size: 9px; line-height: 1.7; box-shadow: 0 8px 25px rgba(0,0,0,.2); }
.tooltip.show { display: block; }
.health-list { display: grid; gap: 0; padding: 0 19px 16px; }
.health-row { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #edefe8; font-size: 10px; }
.health-row span { color: var(--muted); }
.health-row b.ok { color: var(--green); }
.health-row b.warn { color: var(--red); }
.ranking { padding: 0 18px 17px; }
.rank-group { border-top: 1px solid #edefe8; }
.rank-row { width: 100%; min-height: 58px; display: grid; grid-template-columns: 32px minmax(220px,1fr) 130px 100px 110px 20px; align-items: center; gap: 10px; padding: 0; color: inherit; background: transparent; border: 0; font-size: 10px; text-align: left; }
.rank-row.header { min-height: 34px; color: #9b9e95; font-size: 8px; }
.rank-row .title { min-width: 0; display: flex; align-items: center; gap: 10px; }
.rank-row .title img { width: 38px; height: 38px; object-fit: cover; border-radius: 8px; background: #eee; }
.rank-row .title > span { min-width: 0; }
.rank-row .title strong, .rank-row .title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .title small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.rank-row .arrow { color: #aaa; transition: transform .2s; }
.rank-group.expanded > .rank-row .arrow { transform: rotate(180deg); }
.rank-skus { display: none; padding-left: 42px; background: #fafaf6; border-top: 1px solid #edefe8; }
.rank-group.expanded .rank-skus { display: block; }
.rank-sku { min-height: 49px; display: grid; grid-template-columns: minmax(200px,1fr) 130px 100px 110px 20px; align-items: center; gap: 10px; color: inherit; background: transparent; border: 0; border-top: 1px solid #edefe8; text-align: left; font-size: 9px; }
.rank-sku:first-child { border-top: 0; }
.rank-sku strong, .rank-sku small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sku small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.rank-num { color: var(--accent); font-weight: 800; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 13px; padding: 12px; }
.toolbar .search { width: min(300px,100%); }
.check { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.grow { flex: 1; }
#selectedCount { color: var(--muted); font-size: 10px; }
.target-list { display: grid; gap: 11px; }
.target-card { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.user-row { min-height: 72px; display: grid; grid-template-columns: 23px 45px minmax(180px,1fr) 85px 85px 26px; align-items: center; gap: 11px; padding: 10px 16px; cursor: pointer; }
.user-row input, .product-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.avatar, .product-image { object-fit: cover; background: #eceee7; border-radius: 9px; }
.avatar { width: 45px; height: 45px; border-radius: 50%; }
.user-name { min-width: 0; }
.user-name strong, .user-name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name strong { font-size: 12px; }
.user-name span { margin-top: 5px; color: var(--muted); font-size: 8px; }
.user-stat span, .user-stat b { display: block; text-align: right; }
.user-stat span { color: var(--muted); font-size: 8px; }
.user-stat b { margin-top: 4px; font-size: 12px; }
.chevron { color: #aaa; transition: transform .2s; }
.target-card.expanded .chevron { transform: rotate(180deg); }
.products { display: none; border-top: 1px solid var(--line); }
.target-card.expanded .products { display: block; }
.product-row { min-height: 68px; display: grid; grid-template-columns: 23px 43px minmax(220px,1fr) 90px 90px 90px; align-items: center; gap: 11px; padding: 9px 16px 9px 26px; border-top: 1px solid #eff0eb; font-size: 10px; }
.product-row:first-child { border-top: 0; }
.product-image { width: 43px; height: 43px; }
.product-main { min-width: 0; }
.product-main strong, .product-main span { display: block; }
.product-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-main span { margin-top: 4px; color: var(--muted); font-size: 8px; }
.product-row.hidden-product { opacity: .58; background: #f7f7f3; }
.restore { justify-self: end; padding: 5px 8px; color: var(--green); background: var(--green-soft); border: 0; border-radius: 7px; font-size: 8px; }
.schedule-create { margin-bottom: 13px; }
.schedule-create > .muted { margin: 0; padding: 0 19px 17px; font-size: 9px; }
.schedule-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; padding: 0 19px 11px; }
.schedule-form label input { margin-top: 5px; }
.schedule-list, .log-list { padding: 0 18px 16px; }
.schedule-row { min-height: 68px; display: grid; grid-template-columns: 70px minmax(150px,.7fr) minmax(220px,1.2fr) minmax(130px,.7fr) auto; align-items: center; gap: 12px; border-top: 1px solid #edefe8; font-size: 9px; }
.pill { width: fit-content; padding: 5px 8px; color: #8a6e43; background: #fff4d9; border-radius: 7px; font-weight: 800; }
.pill.running, .pill.active { color: var(--green); background: var(--green-soft); }
.pill.cancelled, .pill.failed { color: var(--red); background: #fff0ed; }
.schedule-row strong, .schedule-row span { display: block; }
.schedule-row span { margin-top: 4px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; }
.row-actions button, .text-button { padding: 5px 8px; color: var(--accent); background: transparent; border: 0; font-size: 9px; }
.log-tabs { display: flex; gap: 4px; margin-bottom: 11px; padding: 4px; width: fit-content; background: #e8eae3; border-radius: 10px; }
.log-tabs button { padding: 7px 13px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 10px; }
.log-tabs button.active { color: var(--ink); background: white; box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.log-row { min-height: 61px; display: grid; grid-template-columns: 70px 155px minmax(240px,1fr) 110px; align-items: center; gap: 12px; border-top: 1px solid #edefe8; font-size: 9px; }
.log-row > div strong, .log-row > div span { display: block; }
.log-row > div span, .log-row time { margin-top: 4px; color: var(--muted); }
.log-row p { margin: 0; line-height: 1.5; }
.settings-card { margin-bottom: 13px; padding-bottom: 17px; }
.settings-card > .muted { margin: -3px 19px 14px; font-size: 10px; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); align-items: end; gap: 12px; padding: 0 19px; }
.form-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-grid label input { margin-top: 5px; }
.align-end { align-self: end; }
.switch input { display: none; }
.switch i { width: 40px; height: 23px; display: block; padding: 3px; background: #cdd0c7; border-radius: 20px; transition: .2s; }
.switch i::after { content: ""; width: 17px; height: 17px; display: block; background: white; border-radius: 50%; transition: .2s; box-shadow: 0 2px 5px rgba(0,0,0,.15); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(17px); }
.settings-actions { display: flex; gap: 8px; padding: 0 19px; }
.empty { padding: 28px 12px; color: var(--muted); font-size: 10px; text-align: center; }
dialog { width: min(560px,calc(100vw - 28px)); padding: 0; color: var(--ink); background: var(--panel); border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(25,27,24,.58); backdrop-filter: blur(4px); }
dialog form { padding: 23px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; }
.dialog-head h2 { margin: 0; }
.dialog-head > button { width: 31px; height: 31px; color: var(--muted); background: #f0f1eb; border: 0; border-radius: 9px; font-size: 18px; }
dialog textarea, dialog label input { margin-top: 9px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast-region { position: fixed; z-index: 30; top: 15px; right: 16px; display: grid; gap: 8px; }
.toast { max-width: min(380px,calc(100vw - 32px)); padding: 12px 14px; color: white; background: #262923; border-radius: 10px; box-shadow: 0 12px 35px rgba(0,0,0,.18); font-size: 10px; }
.toast.error { background: #a84239; }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .app { grid-template-columns: 190px minmax(0,1fr); }
  main { padding-inline: 20px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .analysis-filter-grid { grid-template-columns: repeat(3,minmax(120px,1fr)); }
  .rank-row { grid-template-columns: 28px minmax(190px,1fr) 90px 100px 20px; }
  .rank-row > :nth-child(3) { display: none; }
  .rank-sku { grid-template-columns: minmax(180px,1fr) 90px 100px 20px; }
  .rank-sku > :nth-child(2) { display: none; }
  .user-row { grid-template-columns: 23px 45px minmax(150px,1fr) 75px 26px; }
  .user-row .user-stat:nth-of-type(2) { display: none; }
  .product-row { grid-template-columns: 23px 43px minmax(180px,1fr) 75px 75px; }
  .product-row > :nth-child(5) { display: none; }
  .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .app { display: block; }
  .sidebar { display: none; }
  main { padding: 18px 13px 90px; }
  header { margin-bottom: 13px; }
  header h1 { font-size: 22px; }
  .header-actions .button { min-height: 34px; padding: 0 10px; font-size: 10px; }
  .runtime-bar { grid-template-columns: 18px minmax(0,1fr) auto; min-height: 61px; padding: 10px 12px; }
  .progress-box { grid-column: 2 / -1; }
  .runtime-bar #stopButton { grid-column: 3; grid-row: 1; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 19px; }
  .panel-head { padding: 14px; }
  .chart-wrap { height: 230px; padding-inline: 4px; }
  .analysis-filter-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .analysis-filter-grid .button { width: 100%; }
  .rank-row { grid-template-columns: 25px minmax(120px,1fr) 60px 18px; }
  .rank-row > :nth-child(3), .rank-row > :nth-child(5) { display: none; }
  .rank-skus { padding-left: 26px; }
  .rank-sku { grid-template-columns: minmax(120px,1fr) 65px 18px; }
  .rank-sku > :nth-child(2), .rank-sku > :nth-child(4) { display: none; }
  .toolbar { align-items: stretch; }
  .toolbar .search { order: -1; width: 100%; }
  .toolbar .grow { display: none; }
  .toolbar .button { flex: 1; }
  #selectedCount { width: 100%; }
  .user-row { grid-template-columns: 20px 40px minmax(120px,1fr) 50px 20px; padding-inline: 11px; }
  .avatar { width: 40px; height: 40px; }
  .user-row .user-stat:nth-of-type(2) { display: none; }
  .product-row { grid-template-columns: 20px 38px minmax(130px,1fr) 58px; padding: 8px 10px 8px 17px; }
  .product-image { width: 38px; height: 38px; }
  .product-row > :nth-child(5), .product-row > :nth-child(6) { display: none; }
  .schedule-form { grid-template-columns: 1fr; }
  .schedule-row { grid-template-columns: 64px minmax(120px,1fr) auto; padding: 8px 0; }
  .schedule-row > :nth-child(3), .schedule-row > :nth-child(4) { display: none; }
  .log-row { grid-template-columns: 62px minmax(100px,.7fr) minmax(150px,1fr); padding: 8px 0; }
  .log-row time { display: none; }
  .form-grid, .form-grid.two { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5,1fr); padding: 7px 5px calc(7px + env(safe-area-inset-bottom)); background: rgba(24,26,23,.96); backdrop-filter: blur(10px); }
  .mobile-nav button { display: grid; place-items: center; gap: 2px; padding: 4px; color: #94998f; background: transparent; border: 0; font-size: 15px; }
  .mobile-nav button span { font-size: 8px; }
  .mobile-nav button.active { color: white; }
  .mobile-nav button.active:first-letter { color: var(--accent); }
}
