:root {
  color-scheme: dark;
  --bg: #090d10;
  --panel: #11171b;
  --panel-2: #151d22;
  --line: #263138;
  --line-soft: #1e282e;
  --text: #ecf4f1;
  --muted: #8c9a9e;
  --green: #42d49b;
  --green-dim: #163a2f;
  --red: #ff786e;
  --red-dim: #3d211f;
  --amber: #f4ba55;
  --amber-dim: #3b3020;
  --blue: #72b7ff;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background: radial-gradient(circle at 85% -20%, rgba(66,212,155,.09), transparent 34rem), var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.shell { width: min(1560px, 100%); min-height: 100vh; margin: 0 auto; padding: 28px 30px 22px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 5px); align-items: end; gap: 3px; width: 33px; height: 33px; padding: 7px; border: 1px solid #365047; border-radius: 9px; background: #10231d; }
.brand-mark i { display: block; border-radius: 1px; background: var(--green); }
.brand-mark i:nth-child(1) { height: 8px; opacity: .55; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 12px; opacity: .75; }
.eyebrow, .section-kicker { margin: 0 0 4px; color: var(--green); font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: 25px; }
h2 { font-size: 22px; }
.top-actions, .refresh-meta, .modal-actions { display: flex; align-items: center; gap: 10px; }
.connection { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; color: var(--muted); font-size: 13px; }
.connection span { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(244,186,85,.1); }
.connection.online span { background: var(--green); box-shadow: 0 0 0 4px rgba(66,212,155,.1); }
.connection.error span { background: var(--red); }
.button { min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 9px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; transition: .16s ease; }
.button:hover { transform: translateY(-1px); border-color: #41525b; }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { border-color: var(--green); color: #06140f; background: var(--green); box-shadow: 0 8px 28px rgba(66,212,155,.13); }
.button.ghost { color: #c0cdca; background: rgba(255,255,255,.018); }
.button.danger { border-color: #6d3733; color: #ffd0cc; background: #3a1d1b; }
.button.danger:hover { border-color: var(--red); }

main { padding-top: 26px; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { position: relative; min-height: 138px; padding: 19px 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(255,255,255,.025), transparent), var(--panel); }
.metric::after { content: ""; position: absolute; right: -35px; bottom: -50px; width: 130px; height: 130px; border: 1px solid currentColor; border-radius: 50%; opacity: .06; }
.metric-top { display: flex; justify-content: space-between; color: #bdc8c6; font-size: 13px; font-weight: 650; }
.metric-code { color: var(--muted); font: 700 9px/1 ui-monospace, monospace; letter-spacing: .12em; }
.metric strong { display: block; margin-top: 14px; font: 680 39px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -.08em; }
.metric p { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.metric-stock strong { color: var(--green); }
.metric-out strong { color: var(--red); }
.metric-focus strong { color: var(--amber); }

.notice { display: flex; margin-top: 14px; padding: 14px 17px; border: 1px solid #654e25; border-radius: 11px; background: var(--amber-dim); }
.notice div { display: flex; gap: 12px; align-items: baseline; }
.notice strong { color: var(--amber); font-size: 13px; }
.notice span { color: #ceb988; font-size: 12px; }

.workspace { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(17,23,27,.94); box-shadow: var(--shadow); overflow: hidden; }
.workspace-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 17px; }
.refresh-meta { color: var(--muted); font-size: 12px; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #12191d; cursor: pointer; }
.icon-button:hover { border-color: #44565f; }
.icon-button svg, .search-field svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-button.loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.filters { display: grid; grid-template-columns: minmax(240px, 1fr) auto auto; gap: 12px; align-items: center; padding: 13px 22px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line); background: #0e1417; }
.search-field { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #0a0f12; }
.search-field:focus-within { border-color: #3c6e5c; box-shadow: 0 0 0 3px rgba(66,212,155,.06); }
.search-field input { width: 100%; color: var(--text); border: 0; outline: 0; background: transparent; font-size: 13px; }
.search-field kbd { padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; color: #77868a; font: 10px ui-monospace, monospace; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #090e11; }
.segmented button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.segmented button.active { color: #dce8e4; background: #222d32; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.check-filter { display: flex; align-items: center; gap: 7px; color: #b6c1bf; font-size: 12px; cursor: pointer; }
.check-filter input { accent-color: var(--amber); }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1280px; border-collapse: collapse; table-layout: fixed; }
th { padding: 11px 15px; color: #718085; background: #0c1114; text-align: left; font: 700 10px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
th:nth-child(1) { width: 92px; }
th:nth-child(2) { width: 28%; }
th:nth-child(3) { width: 112px; }
th:nth-child(4) { width: 25%; }
th:nth-child(5) { width: 145px; }
th:nth-child(6) { width: 380px; }
td { padding: 14px 15px; border-top: 1px solid var(--line-soft); vertical-align: middle; font-size: 12px; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-in_stock { color: var(--green); border-color: #245843; background: rgba(66,212,155,.06); }
.status-out_of_stock { color: var(--red); border-color: #5b302d; background: rgba(255,120,110,.05); }
.status-error { color: var(--amber); border-color: #654e25; }
.product-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.product-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.favorite-button { flex: 0 0 auto; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 6px; color: #879397; background: transparent; cursor: pointer; font-size: 17px; line-height: 1; opacity: 0; pointer-events: none; transform: scale(.88); transition: color .14s ease, background .14s ease, opacity .14s ease, transform .14s ease; }
.favorite-button:hover { color: var(--amber); background: rgba(244,186,85,.08); }
.favorite-button:focus-visible { opacity: 1; pointer-events: auto; outline: 2px solid var(--amber); outline-offset: 2px; }
.favorite-button.active { color: var(--amber); opacity: 1; pointer-events: auto; transform: scale(1); }
tbody tr:hover .favorite-button { opacity: 1; pointer-events: auto; transform: scale(1); }
.machine { color: #9fb0ad; line-height: 1.45; }
.machine span + span::before { content: " / "; color: #46555a; }
.price { font: 700 13px ui-monospace, monospace; white-space: nowrap; }
.cycle { margin-left: 3px; color: var(--muted); font: 11px ui-sans-serif, sans-serif; }
.network { display: -webkit-box; overflow: hidden; color: #aab8b5; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.network small { color: #68777b; }
.time { color: #a1afad; font: 11px/1.5 ui-monospace, monospace; }
.time small { display: block; color: #647378; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.row-button { display: inline-grid; flex: 0 0 auto; place-items: center; min-width: 35px; height: 31px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; color: #89989b; background: transparent; cursor: pointer; font-size: 11px; text-decoration: none; white-space: nowrap; }
.row-button:hover { color: var(--text); border-color: var(--line); background: #182126; }
.row-button.danger:hover { color: var(--red); border-color: #57302d; }
.row-button.monitor { color: var(--green); border-color: #285a47; background: rgba(66,212,155,.06); }
.paused { opacity: .52; }
.empty { padding: 70px 20px; text-align: center; }
.empty-icon { display: block; margin-bottom: 12px; color: #46565b; font-size: 38px; }
.empty strong { font-size: 14px; }
.empty p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }

footer { display: flex; gap: 22px; padding: 15px 4px 0; color: #627075; font: 10px ui-monospace, monospace; }
footer span:last-child { margin-left: auto; }
footer b { color: #859397; font-weight: 500; }

.modal { width: min(640px, calc(100% - 28px)); padding: 0; border: 1px solid #344148; border-radius: 15px; color: var(--text); background: transparent; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(2,6,8,.78); backdrop-filter: blur(4px); }
.modal-card { padding: 22px; background: #12191d; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.close-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #0d1316; cursor: pointer; font-size: 22px; line-height: 1; }
.form-field { display: grid; gap: 8px; margin-top: 16px; color: #b5c1be; font-size: 12px; font-weight: 650; }
.form-field small { color: var(--muted); font-weight: 400; }
.form-field input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--text); background: #090e11; }
.form-field input:focus { border-color: #3c6e5c; box-shadow: 0 0 0 3px rgba(66,212,155,.06); }
.modal-actions { justify-content: flex-end; margin-top: 23px; }
.form-error { margin: 13px 0 0; color: var(--red); font-size: 12px; }
.form-hint { margin: 11px 0 0; color: #718085; font-size: 11px; line-height: 1.5; }
#confirmDialog { width: min(520px, calc(100% - 28px)); }
.confirm-card { width: 100%; max-width: none; }
.confirm-message { margin: 0; color: #b7c3c0; font-size: 13px; line-height: 1.7; }
.monitor-dialog { width: min(680px, calc(100% - 28px)); }
.monitor-picker { display: flex; max-height: min(760px, calc(100vh - 40px)); flex-direction: column; }
.monitor-search { flex: 0 0 auto; }
.monitor-options { display: grid; gap: 8px; margin-top: 14px; overflow-y: auto; overscroll-behavior: contain; }
.monitor-option { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 14px; border: 1px solid var(--line-soft); border-radius: 9px; background: #0c1114; }
.monitor-option > div { min-width: 0; }
.monitor-option strong { display: block; overflow: hidden; color: #dce6e3; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.monitor-option span { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.select-monitor { flex: 0 0 auto; border-color: #285a47; color: var(--green); background: rgba(66,212,155,.06); }
.monitor-empty { margin-top: 14px; padding: 34px 18px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); text-align: center; font-size: 12px; }
.monitor-actions { flex: 0 0 auto; border-top: 1px solid var(--line-soft); padding-top: 18px; }
.detail-card { max-height: min(820px, calc(100vh - 40px)); overflow-y: auto; }
.detail-status { display: flex; justify-content: space-between; gap: 10px; padding: 13px 0 18px; border-bottom: 1px solid var(--line); }
.detail-link { overflow: hidden; color: var(--blue); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; text-decoration: none; }
.config-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--line); }
.config-item { min-height: 68px; padding: 11px 13px; background: #0e1417; }
.config-item dt { margin-bottom: 6px; color: #69787c; font: 700 9px ui-monospace, monospace; letter-spacing: .1em; }
.config-item dd { margin: 0; color: #d3ddda; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.detail-section { margin-top: 17px; }
.detail-section h3 { margin: 0 0 7px; color: #79898d; font: 700 10px ui-monospace, monospace; letter-spacing: .1em; }
.detail-section p { margin: 0; padding: 11px 13px; border: 1px solid var(--line-soft); border-radius: 8px; color: #aebbb8; background: #0c1114; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.diff-text { color: var(--amber) !important; border-color: #4a3b22 !important; background: #19160f !important; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(390px, calc(100% - 48px)); padding: 12px 15px; border: 1px solid #345448; border-radius: 9px; color: #d8e8e2; background: #12251e; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #613633; color: #ffd0cc; background: #2a1716; }

.login-page { min-height: 100vh; background: radial-gradient(circle at 50% -15%, rgba(66,212,155,.13), transparent 30rem), var(--bg); }
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 27px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(255,255,255,.025), transparent), var(--panel); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 13px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.login-copy { padding-top: 25px; }
.login-copy h2 { font-size: 25px; }
.login-copy > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.login-form { margin-top: 21px; }
.login-submit { width: 100%; margin-top: 20px; }
.login-foot { margin: 18px 0 0; color: #657479; text-align: center; font-size: 11px; }

@media (max-width: 1050px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr auto; }
  .check-filter { grid-column: 1 / -1; }
  th:nth-child(4), td:nth-child(4) { display: none; }
  th:nth-child(2) { width: 40%; }
}

@media (max-width: 720px) {
  .shell { padding: 18px 14px; }
  .topbar { align-items: flex-start; padding-bottom: 19px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .connection { width: 100%; justify-content: flex-end; margin: 0; }
  .summary { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric { min-height: 118px; padding: 15px; }
  .metric strong { font-size: 32px; }
  .workspace-head { flex-wrap: wrap; gap: 14px; padding: 17px; }
  .filters { grid-template-columns: 1fr; padding: 12px 14px; }
  .segmented { overflow-x: auto; }
  .check-filter { grid-column: auto; }
  table, thead, tbody, tr, td { display: block; }
  table { min-width: 0; }
  thead { display: none; }
  tbody { padding: 0 12px 12px; }
  tbody tr { position: relative; margin-top: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #0d1316; }
  td { padding: 4px 0; border: 0; }
  td:nth-child(1) { margin-bottom: 7px; }
  td:nth-child(3) { position: absolute; top: 15px; right: 14px; }
  td:nth-child(4) { display: block; margin-top: 7px; }
  td:nth-child(5) { margin-top: 8px; }
  .row-actions { flex-wrap: wrap; justify-content: flex-start; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
  footer { flex-wrap: wrap; gap: 8px 15px; }
  footer span:last-child { width: 100%; margin: 0; }
  .config-grid { grid-template-columns: 1fr; }
  .monitor-option { align-items: flex-start; }
}

@media (hover: none) {
  .favorite-button { opacity: 1; pointer-events: auto; transform: scale(1); }
}

@media (max-width: 470px) {
  .brand .eyebrow { display: none; }
  h1 { font-size: 20px; }
  .button { padding: 0 11px; }
  #syncButton { display: none; }
  .summary { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 105px; }
  .metric p { display: none; }
}
