:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #20242b;
  background: #f7f8fa;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --blue: #0876df;
  --blue-dark: #0565c2;
  --line: #dfe3e8;
  --muted: #6d7580;
  --soft: #f3f5f7;
  --green: #159455;
  --red: #c73d44;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
[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; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); background: #fff; }
.sidebar { display: flex; flex-direction: column; min-height: 100vh; padding: 23px 14px 12px; border-right: 1px solid var(--line); background: #fbfcfd; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 30px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 16px; line-height: 20px; font-weight: 650; }
.sidebar-brand span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand-mark { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 12px; color: #fff; background: var(--blue); font-size: 15px; font-weight: 700; }
.brand-mark-small { width: 34px; height: 34px; border-radius: 9px; font-size: 12px; }
.sidebar-label { padding: 0 11px 9px; color: #89919b; font-size: 11px; font-weight: 650; }
.sidebar-label-spaced { margin-top: 31px; }
.side-nav { display: grid; gap: 3px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; min-height: 36px; padding: 0 11px; border: 0; border-radius: 5px; color: #414852; background: transparent; text-align: left; font-size: 13px; }
.nav-item:hover { background: #f0f3f6; }
.nav-item.active { color: #075fba; background: #eaf3fd; font-weight: 600; }
.nav-count { color: #7c8590; font-size: 11px; font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: #075fba; }
.connection-row { display: flex; align-items: center; gap: 8px; min-height: 33px; padding: 0 10px; color: #49515b; font-size: 12px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #db9a25; }
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }
.status-dot-muted { background: #aab1ba; }
.connection-state { margin-left: auto; color: #89919b; font-size: 11px; }
.sidebar-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.account-row { display: flex; align-items: center; gap: 9px; padding: 2px 5px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #285b91; background: #e6eff8; font-size: 12px; font-weight: 650; }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy span { display: block; }
.account-copy strong { font-size: 12px; font-weight: 600; }
.account-copy span { margin-top: 2px; color: var(--muted); font-size: 11px; }

.workspace { min-width: 0; background: #fff; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 61px; padding: 0 34px; border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; align-items: center; gap: 10px; color: #6f7781; font-size: 12px; }
.breadcrumb strong { color: #252a31; font-weight: 600; }
.breadcrumb-separator { color: #c2c7ce; }
.topbar-actions { display: flex; align-items: center; gap: 17px; }
.last-updated { color: #8b929b; font-size: 11px; }
.page-content { max-width: 1400px; margin: 0 auto; padding: 31px 34px 21px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.page-heading h1 { margin: 0; font-size: 23px; line-height: 30px; font-weight: 650; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 13px; border: 1px solid transparent; border-radius: 5px; font-size: 12px; font-weight: 550; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.button-primary { border-color: var(--blue); color: #fff; background: var(--blue); }
.button-primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.button-primary:disabled { cursor: wait; opacity: .65; }
.button-subtle { border-color: #cbd1d8; color: #414852; background: #fff; }
.button-subtle:hover { border-color: #9da6b0; background: #f8f9fa; }
.button-plus { font-size: 19px; line-height: 12px; font-weight: 400; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 30px; padding: 0 7px; border: 1px solid transparent; border-radius: 4px; color: #626b76; background: transparent; font-size: 11px; }
.icon-button:hover { color: #20242b; background: #eef1f4; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.metric { min-height: 111px; padding: 18px 18px 15px 0; }
.metric + .metric { padding-left: 22px; border-left: 1px solid #e8ebef; }
.metric-label, .metric-detail { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 6px; color: #252a31; font-size: 21px; line-height: 26px; font-weight: 620; font-variant-numeric: tabular-nums; }
.metric-detail { margin-top: 3px; font-size: 10px; }
.storage-track { width: min(180px, 100%); height: 4px; margin-top: 8px; overflow: hidden; border-radius: 2px; background: #e9edf1; }
.storage-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #2787dd; transition: width .2s; }

.content-toolbar { display: flex; align-items: center; justify-content: space-between; min-height: 57px; gap: 12px; border-bottom: 1px solid var(--line); }
.filter-tabs { display: flex; align-items: center; align-self: stretch; gap: 20px; }
.filter-tab { position: relative; padding: 1px 0 0; border: 0; color: #737b85; background: transparent; font-size: 12px; white-space: nowrap; }
.filter-tab:hover, .filter-tab.selected { color: #076bc8; }
.filter-tab.selected { font-weight: 600; }
.filter-tab.selected::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--blue); content: ""; }
.search-box { display: flex; align-items: center; width: 210px; height: 30px; padding: 0 9px; border: 1px solid #d9dee4; border-radius: 4px; background: #fff; }
.search-box:focus-within { border-color: #70aee9; box-shadow: 0 0 0 2px #e5f1fd; }
.search-icon { position: relative; width: 13px; height: 13px; flex: 0 0 13px; margin-right: 8px; border: 1.5px solid #89919b; border-radius: 50%; }
.search-icon::after { position: absolute; right: -4px; bottom: -2px; width: 5px; height: 1.5px; transform: rotate(45deg); background: #89919b; content: ""; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: #2a3038; background: transparent; font-size: 11px; }
.search-box input::placeholder { color: #9ba2ab; }
.table-wrap { position: relative; min-height: 250px; overflow-x: auto; }
.task-table { width: 100%; min-width: 690px; border-collapse: collapse; table-layout: fixed; }
.task-table th { height: 39px; padding: 0 10px; border-bottom: 1px solid #e7eaee; color: #838b95; font-size: 10px; font-weight: 550; text-align: left; white-space: nowrap; }
.task-table td { height: 66px; padding: 10px; border-bottom: 1px solid #edf0f2; color: #454d57; font-size: 11px; vertical-align: middle; }
.task-table tbody tr:hover { background: #fafbfd; }
.name-col { width: 38%; padding-left: 0 !important; }
.task-table td:first-child { padding-left: 0; }
.progress-col { width: 19%; }
.size-col { width: 12%; }
.speed-col { width: 13%; }
.state-col { width: 12%; }
.actions-col { width: 6%; text-align: right !important; }
.task-name { display: block; overflow: hidden; color: #252a31; font-size: 12px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.task-subtitle { display: block; overflow: hidden; margin-top: 5px; color: #9299a2; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.progress-line { width: 100%; height: 5px; overflow: hidden; border-radius: 3px; background: #edf0f3; }
.progress-line span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.progress-line.complete span { background: var(--green); }
.progress-label { display: flex; justify-content: space-between; margin-top: 5px; color: #7b838d; font-size: 10px; font-variant-numeric: tabular-nums; }
.status-label { display: inline-flex; align-items: center; gap: 6px; color: #5b636d; font-size: 10px; white-space: nowrap; }
.status-label::before { width: 6px; height: 6px; border-radius: 50%; background: #9ca4ad; content: ""; }
.status-label.downloading::before, .status-label.metaDL::before, .status-label.checkingDL::before { background: var(--blue); }
.status-label.completed::before, .status-label.uploading::before, .status-label.stalledUP::before { background: var(--green); }
.status-label.paused::before, .status-label.stoppedDL::before, .status-label.stoppedUP::before { background: #9ca4ad; }
.status-label.error::before, .status-label.missingFiles::before { background: var(--red); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-action { min-width: 26px; height: 26px; padding: 0 5px; border: 0; border-radius: 4px; color: #68717b; background: transparent; font-size: 10px; }
.row-action:hover { color: #075fba; background: #eaf3fd; }
.row-action.delete:hover { color: var(--red); background: #fff0f0; }
.empty-state { display: flex; min-height: 235px; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: var(--muted); text-align: center; }
.empty-symbol { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 3px; border: 1px solid #dfe5eb; border-radius: 10px; color: #5785b3; background: #f7fafe; font-size: 12px; font-weight: 650; }
.empty-state strong { color: #3b424a; font-size: 13px; font-weight: 600; }
.empty-state span { font-size: 11px; }
.empty-state .button { margin-top: 4px; }
.loading-state { padding: 35px 0; color: #8a929c; font-size: 11px; text-align: center; }
.workspace-footer { display: flex; justify-content: space-between; margin-top: 15px; padding-top: 11px; border-top: 1px solid #edf0f2; color: #8a929c; font-size: 10px; }

.login-view { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: #f7f8fa; }
.login-form { width: min(100%, 360px); padding: 31px 32px 29px; border: 1px solid #e0e4e8; border-radius: 7px; background: #fff; box-shadow: 0 7px 24px rgb(27 39 51 / 5%); }
.login-form .brand-mark { margin-bottom: 21px; }
.eyebrow { margin: 0 0 7px; color: #7d8792; font-size: 10px; font-weight: 650; letter-spacing: 0; }
.login-form h1 { margin: 0 0 23px; font-size: 22px; font-weight: 650; }
.login-form label, .add-panel > label { display: block; margin-bottom: 7px; color: #4f5761; font-size: 11px; font-weight: 550; }
.login-form input { width: 100%; height: 37px; padding: 0 10px; border: 1px solid #cfd5dc; border-radius: 4px; outline: 0; }
.login-form input:focus, textarea:focus { border-color: #70aee9; box-shadow: 0 0 0 2px #e5f1fd; }
.button-wide { width: 100%; }
.form-error { min-height: 16px; margin: 7px 0 9px; color: var(--red); font-size: 10px; }

.add-dialog { width: min(100% - 28px, 490px); max-width: 490px; padding: 0; border: 1px solid #d9dee4; border-radius: 7px; color: #20242b; background: #fff; box-shadow: 0 20px 70px rgb(19 33 48 / 22%); }
.add-dialog::backdrop { background: rgb(21 31 43 / 34%); }
.add-dialog form { padding: 23px 24px 19px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 18px; font-weight: 640; }
.dialog-heading .eyebrow { margin-bottom: 5px; }
.close-button { width: 30px; font-size: 21px; }
.mode-switch { display: flex; gap: 5px; margin: 17px 0; padding: 3px; border-radius: 5px; background: #f1f3f5; }
.mode-option { min-height: 30px; flex: 1; border: 0; border-radius: 4px; color: #737b85; background: transparent; font-size: 11px; }
.mode-option.selected { color: #2e3740; background: #fff; box-shadow: 0 1px 3px rgb(22 35 48 / 10%); font-weight: 600; }
.add-panel { min-height: 128px; }
.add-panel textarea { display: block; width: 100%; min-height: 96px; resize: vertical; padding: 10px; border: 1px solid #cfd5dc; border-radius: 4px; outline: 0; color: #2a3038; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5; }
.upload-area { display: flex !important; min-height: 96px; flex-direction: column; align-items: center; justify-content: center; gap: 7px; border: 1px dashed #bcc7d2; border-radius: 5px; background: #fafbfd; cursor: pointer; }
.upload-area:hover { border-color: #6aa9e7; background: #f6faff; }
.upload-area input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.upload-title { color: #3c4650; font-size: 12px; font-weight: 550; }
.upload-detail { max-width: 100%; overflow: hidden; padding: 0 8px; color: #89919b; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 3px; }
.toast-region { position: fixed; right: 22px; bottom: 19px; z-index: 10; display: grid; gap: 8px; }
.toast { max-width: min(360px, calc(100vw - 34px)); padding: 10px 13px; border: 1px solid #dfe4e9; border-radius: 5px; color: #313942; background: #fff; box-shadow: 0 5px 20px rgb(20 33 46 / 10%); font-size: 11px; }
.toast.error { border-color: #f1cdcd; color: #a72c34; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 184px minmax(0, 1fr); }
  .topbar { padding: 0 22px; }
  .page-content { padding: 26px 22px 20px; }
  .metric { padding-right: 10px; }
  .metric + .metric { padding-left: 13px; }
  .name-col { width: 33%; }
  .progress-col { width: 20%; }
}
@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { min-height: 0; flex-direction: row; align-items: center; gap: 8px; padding: 9px 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { flex: 0 0 auto; padding: 0 9px 0 0; }
  .sidebar-brand span, .sidebar-label, .sidebar-label-spaced, .connection-row, .sidebar-bottom { display: none; }
  .side-nav { display: flex; min-width: 0; flex: 1; justify-content: flex-end; gap: 3px; }
  .nav-item { min-height: 31px; padding: 0 8px; font-size: 10px; }
  .nav-count { display: none; }
  .topbar { min-height: 48px; padding: 0 15px; }
  .topbar-actions { gap: 8px; }
  .last-updated { display: none; }
  .page-content { padding: 19px 15px 18px; }
  .page-heading { align-items: flex-start; padding-bottom: 16px; }
  .page-heading h1 { font-size: 20px; }
  .page-heading p { max-width: 230px; line-height: 1.45; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 86px; padding: 13px 10px 11px 0; }
  .metric:nth-child(3) { padding-left: 0; border-left: 0; border-top: 1px solid #e8ebef; }
  .metric:nth-child(4) { border-top: 1px solid #e8ebef; }
  .metric + .metric { padding-left: 12px; }
  .metric:nth-child(3) { padding-left: 0; }
  .metric strong { margin-top: 4px; font-size: 18px; line-height: 23px; }
  .content-toolbar { align-items: flex-start; flex-direction: column-reverse; justify-content: flex-start; gap: 0; padding-top: 10px; }
  .search-box { align-self: stretch; width: 100%; margin-bottom: 5px; }
  .filter-tabs { width: 100%; min-height: 39px; justify-content: space-between; gap: 9px; overflow-x: auto; }
  .filter-tab { font-size: 11px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
  .task-table { min-width: 680px; }
  .workspace-footer { gap: 8px; font-size: 9px; }
  .workspace-footer span:last-child { text-align: right; }
  .login-form { padding: 26px 23px 22px; }
  .add-dialog form { padding: 19px 17px 16px; }
}
