/* ============================================================
   dshwork.app 控制台 —— 设计语言基准
   ------------------------------------------------------------
   复刻 zipflow.xyz 的控制台设计语言：
   - DeepSeek 式 260px 侧栏 + 居中 ~936px 内容列
   - 深蓝液态渐变主按钮（#4d6bfe 主色，135deg 渐变）
   - 浅色为默认，dark 块覆盖
   组件只消费语义 token，不写页面私有颜色。
   ============================================================ */

:root {
  --font-display: "Montserrat", "Avenir Next", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "DM Sans", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --radius-menu: 12px;
  --sidebar-w: 260px;
  --gutter: 40px;
  --content-max: 936px;

  --duration-fast: 150ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- light（默认） ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f7fb;
  --sidebar: #fbfbfe;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e9edf6;

  --text: #1e232c;
  --text-2: #5a6478;
  --text-3: #8891a5;
  --text-muted: #aeb5c4;

  --border-l1: rgba(28, 45, 76, 0.05);
  --border-l2: rgba(28, 45, 76, 0.1);
  --border-l3: rgba(28, 45, 76, 0.15);

  --accent: #4d6bfe;
  --accent-hover: #3a5bef;
  --accent-active: #3350e0;
  --on-accent: #ffffff;
  --accent-soft: rgba(77, 107, 254, 0.1);
  --gradient: linear-gradient(135deg, #5b7cfa 0%, #4d6bfe 45%, #3a65c2 100%);

  --nav-hover: #f1f3f9;
  --nav-active: rgba(77, 107, 254, 0.09);

  --success: #16a34a;
  --success-soft: #ecfdf3;
  --success-border: rgba(22, 163, 74, 0.32);
  --warning: #f59e0b;
  --warning-soft: #fdf4e3;
  --warning-border: rgba(245, 158, 11, 0.32);
  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.1);
  --danger-border: rgba(229, 72, 77, 0.32);
  --info: #4d6bfe;
  --info-soft: rgba(77, 107, 254, 0.1);
  --info-border: rgba(77, 107, 254, 0.3);
}

/* ---------- dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1118;
  --sidebar: #131722;
  --surface: #1a2030;
  --surface-2: #232a3d;
  --surface-3: #2c3449;

  --text: #f4f6fb;
  --text-2: #cbd2e0;
  --text-3: #9aa3b8;
  --text-muted: #6b7385;

  --border-l1: rgba(255, 255, 255, 0.06);
  --border-l2: rgba(255, 255, 255, 0.1);
  --border-l3: rgba(255, 255, 255, 0.15);

  --accent: #679efe;
  --accent-hover: #8bb2ff;
  --accent-active: #9bc0ff;
  --on-accent: #ffffff;
  --accent-soft: rgba(103, 158, 254, 0.16);
  --gradient: linear-gradient(135deg, #6d8bff 0%, #4d6bfe 45%, #4a6fe0 100%);

  --nav-hover: #1d2436;
  --nav-active: rgba(103, 158, 254, 0.14);

  --success: #4ade80;
  --success-soft: #10301f;
  --success-border: rgba(74, 222, 128, 0.4);
  --warning: #fbbf24;
  --warning-soft: #2b2415;
  --warning-border: rgba(251, 191, 36, 0.4);
  --danger: #f87171;
  --danger-soft: rgba(229, 72, 77, 0.16);
  --danger-border: rgba(248, 113, 113, 0.4);
  --info: #679efe;
  --info-soft: rgba(103, 158, 254, 0.16);
  --info-border: rgba(103, 158, 254, 0.4);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
html { scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.6; }
a { color: inherit; }
code, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); }

* { scrollbar-width: thin; scrollbar-color: var(--border-l3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-l3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell / sidebar ---------- */
.console-shell { min-height: 100vh; background: var(--bg); color: var(--text); }

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-inline-end: 1px solid var(--border-l1);
  padding: 12px;
  overflow-y: auto;
  z-index: 300;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-menu);
  text-decoration: none;
  color: var(--text);
}
.brand:hover { background: var(--nav-hover); }
.brand-mark { width: 28px; height: 28px; flex: none; border-radius: 8px; overflow: hidden; display: grid; place-items: center; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; flex: 1; min-width: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-menu);
  color: var(--text-3);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.nav-item:hover { background: var(--nav-hover); color: var(--text); }
.nav-item.active { background: var(--nav-active); color: var(--text); }
.nav-icon { display: grid; place-items: center; flex: none; width: 21px; height: 21px; }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-label { font-size: 14px; font-weight: 500; line-height: 25px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot { border-top: 1px solid var(--border-l1); padding-top: 8px; margin-top: 12px; }
.account { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border-radius: 12px; background: transparent; border: 0; color: var(--text); text-align: start; }
.account:hover { background: var(--nav-hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 14px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-meta { min-width: 0; flex: 1; }
.account-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-username { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-utils { display: flex; gap: 8px; align-items: center; padding-top: 8px; }

/* ---------- content column ---------- */
.content { margin-inline-start: var(--sidebar-w); min-height: 100vh; padding: 32px var(--gutter) 96px; width: calc(100% - var(--sidebar-w)); }
.content > .content-inner { margin-inline: auto; max-width: var(--content-max); width: 100%; }

.page-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border-l1);
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.page-kicker { color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 4px; }
.page-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 32px; margin: 0; }
.page-desc { color: var(--text-3); font-size: 14px; margin: 4px 0 0; max-width: 72ch; }

/* ---------- buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  padding: 6px 18px;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
  white-space: nowrap;
}
.button:active { transform: translateY(1px); }
.button.primary {
  background: var(--gradient);
  color: var(--on-accent);
  box-shadow: 0 4px 12px rgba(115, 163, 210, 0.22);
}
.button.primary:hover { box-shadow: 0 8px 18px rgba(115, 163, 210, 0.3); }
.button.secondary { background: transparent; border-color: var(--border-l2); color: var(--text); }
.button.secondary:hover { border-color: var(--border-l3); background: var(--nav-hover); }
.button.ghost { background: transparent; color: var(--text-2); }
.button.ghost:hover { background: var(--nav-hover); }
.button.danger { background: transparent; border-color: var(--danger-border); color: var(--danger); }
.button.danger:hover { background: var(--danger-soft); }
.button.sm { font-size: 13px; min-height: 30px; padding: 4px 14px; }
.button.full { width: 100%; }
.button .btn-icon { display: inline-flex; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-l2);
  background: var(--surface);
  color: var(--text-2);
  transition: border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.icon-btn:hover { border-color: var(--border-l3); color: var(--text); }
.icon-btn.danger:hover { border-color: var(--danger-border); color: var(--danger); background: var(--danger-soft); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- metrics ---------- */
.metric-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.metric-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-l1);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-height: 100px;
  min-width: 0;
}
.metric-label { color: var(--text-3); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.metric-value { color: var(--text); font: 600 22px/1.25 var(--font-mono); font-variant-numeric: tabular-nums; margin-top: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-meta { color: var(--text-3); font-size: 11px; }

/* ---------- panels ---------- */
.stack { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); box-shadow: 0 1px 2px rgba(20, 36, 66, 0.03), 0 4px 16px rgba(20, 36, 66, 0.05); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 12px 20px; border-bottom: 1px solid var(--border-l1); }
.panel-title { display: flex; align-items: center; gap: 8px; color: var(--text); font-family: var(--font-display); font-size: 13px; font-weight: 700; }
.panel-title .panel-title-icon { color: var(--accent); display: inline-flex; }
.panel-body { padding: 16px 20px; min-width: 0; }
.panel-body.flush { padding: 0; }
.panel-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--border-l1); color: var(--text-3); font-size: 12px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 560px; }
.table th { border-bottom: 1px solid var(--border-l2); color: var(--text-3); font-size: 12px; font-weight: 500; padding: 14px 16px; text-align: start; white-space: nowrap; }
.table td { border-bottom: 1px solid var(--border-l1); color: var(--text); padding: 14px 16px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--accent-soft); }
.table .num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-primary { font-weight: 500; }
.cell-sub { color: var(--text-3); font-size: 12px; }
.row-actions { display: inline-flex; gap: 6px; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty p { margin: 0; max-width: 46ch; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select {
  background: var(--surface-2);
  border: 1px solid var(--border-l2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  min-height: 38px;
  padding: 6px 12px;
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field .field-hint { color: var(--text-3); font-size: 12px; }

/* ---------- auth / login ---------- */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card {
  width: min(100%, 440px);
  background: var(--surface);
  border: 1px solid var(--border-l2);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, 0.08);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 30px; height: 30px; }
.auth-brand strong { font-size: 15px; font-weight: 700; }
.auth-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.25; margin: 0; }
.auth-sub { color: var(--text-2); font-size: 14px; margin: 8px 0 0; line-height: 1.6; }
.auth-oauth { margin-top: 24px; display: grid; gap: 10px; }
.oauth-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border-l2);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.oauth-button:hover { background: var(--nav-hover); border-color: var(--border-l3); }
.oauth-button svg { flex: none; }
.auth-error {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
}
.auth-note { margin-top: 20px; color: var(--text-3); font-size: 12px; line-height: 1.6; text-align: center; }
.auth-back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; text-decoration: none; margin-top: 20px; }
.auth-back:hover { color: var(--text); }

/* ---------- inline code / link rows ---------- */
.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border-l1);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border-l1); }
.info-row:last-child { border-bottom: 0; }
.info-label { color: var(--text-3); font-size: 13px; }
.info-value { color: var(--text-2); font-size: 13px; font-weight: 500; text-align: end; word-break: break-all; }

/* ---------- danger zone ---------- */
.danger-zone { border-color: var(--danger-border); }
.danger-zone .panel-head { border-bottom-color: var(--danger-border); }
.danger-zone .panel-title { color: var(--danger); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 36, 66, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 500;
  animation: modal-backdrop-in 180ms var(--ease);
}
.modal {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--border-l2);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.24);
  padding: 24px;
  animation: modal-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 0; }
.modal-body { font-size: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@keyframes modal-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- toast ---------- */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 600; width: min(92vw, 420px); }
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-l2);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.18);
  color: var(--text);
  font-size: 14px;
  animation: toast-in 220ms var(--ease);
}
.toast.success { border-color: var(--success-border); }
.toast.error { border-color: var(--danger-border); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- loading ---------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px; color: var(--text-3); font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-l3); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; --gutter: 20px; }
  .sidebar { transform: translateX(-100%); transition: transform 200ms var(--ease); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-inline-start: 0; width: 100%; padding: 20px var(--gutter) 96px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-bar { display: flex; }
}

/* mobile top bar (only visible when sidebar is hidden) */
.mobile-bar { display: none; align-items: center; gap: 10px; padding: 12px 0 20px; }
.mobile-bar .brand { padding: 0; height: auto; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
