/* 数据湖管理后台的主题：设计令牌 + 应用外壳（侧栏、顶栏），叠加在 Pico 之上。
   与 webllm-1023 的 theme.css 使用同一套令牌，默认深色，可切换浅色。 */

:root:root {
  --font-sans: "IBM Plex Sans", "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  --radius-sm: 0.5rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --sidebar-w: 14.5rem;
  --content-max: 84rem;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 150ms;
  --dur: 200ms;

  --pico-font-family: var(--font-sans);
  --pico-font-family-monospace: var(--font-mono);
  --pico-font-size: 100%;
  --pico-line-height: 1.55;
  --pico-border-radius: var(--radius);
  --pico-form-element-spacing-vertical: 0.5rem;
  --pico-form-element-spacing-horizontal: 0.75rem;
  --pico-transition: var(--dur) var(--ease);
  --pico-text-decoration: none;
}

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 60; padding: .5rem .75rem; background: var(--accent); color: var(--accent-fg); border-radius: var(--radius-sm); }

a { text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
.sidebar a:hover, .brand:hover, [role="button"]:hover { text-decoration: none; }

/* 深色（默认） */
:root:not([data-theme]),
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-elev: #111a2e;
  --surface: #151f35;
  --surface-2: #1b2640;
  --border: #26324b;
  --border-strong: #3a4865;
  --fg: #e8edf6;
  --fg-muted: #94a3b8;
  --fg-subtle: #8a98b0;
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --accent-fg: #06210f;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --link: #4ade80;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --ring: rgba(74, 222, 128, 0.55);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

/* 浅色 */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-elev: #fcfdfe;
  --surface: #fcfdfe;
  --surface-2: #f1f5f9;
  --border: #dde3ec;
  --border-strong: #c2cad8;
  --fg: #1a2233;
  --fg-muted: #5b6577;
  --fg-subtle: #6b7689;
  --accent: #16a34a;
  --accent-strong: #15803d;
  --accent-fg: #ffffff;
  --accent-soft: rgba(22, 163, 74, 0.1);
  --link: #15803d;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --ring: rgba(22, 163, 74, 0.35);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
}

/* 用 :root:root 提高优先级，覆盖 Pico 自带的亮暗选择器（它们的特异性同为 0,2,0 或更高） */
:root:root {
  --pico-background-color: var(--bg);
  --pico-color: var(--fg);
  --pico-h1-color: var(--fg);
  --pico-h2-color: var(--fg);
  --pico-h3-color: var(--fg);
  --pico-muted-color: var(--fg-muted);
  --pico-muted-border-color: var(--border);
  --pico-primary: var(--link);
  --pico-primary-background: var(--accent);
  --pico-primary-border: var(--accent);
  --pico-primary-hover-background: var(--accent-strong);
  --pico-primary-hover-border: var(--accent-strong);
  --pico-primary-focus: var(--ring);
  --pico-primary-inverse: var(--accent-fg);
  --pico-secondary-background: var(--surface-2);
  --pico-secondary-border: var(--border-strong);
  --pico-secondary-hover-background: var(--surface-2);
  --pico-secondary-inverse: var(--fg);
  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--border);
  --pico-card-sectioning-background-color: var(--surface-2);
  --pico-box-shadow: var(--shadow);
  --pico-form-element-background-color: var(--bg-elev);
  --pico-form-element-border-color: var(--border-strong);
  --pico-form-element-color: var(--fg);
  --pico-form-element-focus-color: var(--ring);
  --pico-table-border-color: var(--border);
  --pico-ins-color: var(--accent);
  --pico-del-color: var(--danger);
}

/* ---------- 应用外壳 ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.topbar { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.975rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}
.brand:hover { color: var(--fg); }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
}

.sidebar nav { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.sidebar nav ul {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  margin: 0 0 0.5rem;
  padding: 0;
}
.sidebar nav li { display: block; list-style: none; padding: 0; margin: 0; }

.nav-group {
  margin: 0.75rem 0 0.25rem;
  padding: 0 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

.sidebar nav li a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.25rem;
  margin: 0;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar nav li a.nav-link:hover { background: var(--surface-2); color: var(--fg); }
.sidebar nav li a.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--fg);
  font-weight: 500;
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar nav li a.nav-link[aria-current="page"] .icon { color: var(--accent); }

.sidebar-foot {
  flex: none;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.icon-btn.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: auto;
  min-height: 2.25rem;
  min-width: 2.25rem;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.875rem;
  box-shadow: none;
}
.icon-btn.icon-btn:hover { background: var(--surface-2); color: var(--fg); border-color: var(--border); }

.theme-toggle { width: 100%; justify-content: flex-start; }
.sidebar-tools { display: flex; gap: 0.25rem; }
.theme-icon-light { display: none; }
:root[data-theme="light"] .theme-icon-light { display: block; }
:root[data-theme="light"] .theme-icon-dark { display: none; }

.app-shell > .content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.75rem 2.25rem 3rem;
  min-width: 0;
}

.nav-backdrop { display: none; }

/* ---------- 页面与面板 ---------- */
.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
.page-head p { margin: 0; }
.eyebrow {
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
.muted { color: var(--fg-muted); }
.ok { color: var(--accent); }
.err { color: var(--danger); }
ul.err { list-style: none; padding-left: 0; }

.cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  margin-bottom: 1rem;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.panel h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.panel form { margin-bottom: 0; }

.grid {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}
.grid label { margin-bottom: 0; }

.stage-list { list-style: none; padding-left: 0; margin: 0; }
.stage-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.stage-list li:last-child { border-bottom: 0; }

.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 36rem; margin-bottom: 0; }
.table-wrap td, .table-wrap th { vertical-align: middle; }
.table-wrap button { margin: 0; padding: .35rem .75rem; font-size: .85rem; }

/* ---------- 窄屏：侧栏收起为抽屉 ---------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); align-content: start; }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .5rem;
    height: 3.25rem;
    padding: 0 .75rem;
    background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
    border-bottom: 1px solid var(--border);
  }
  .brand-compact { padding: 0; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(18rem, 85vw);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, .45);
  }

  .app-shell > .content { padding: 1.25rem 1rem 2rem; }
}

/* ---------- 登录页 ---------- */
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  width: 100%;
  max-width: 22rem;
  padding: 2rem 1.75rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}
.login-card .brand { margin-bottom: 1.5rem; padding: 0; }
.login-card h1 { font-size: 1.25rem; margin-bottom: 1.25rem; }
.login-card button[type="submit"] { width: 100%; margin-top: .5rem; }
.login-card .note { font-size: .8rem; margin-top: 1rem; }

/* ---------- 侧栏账号 ---------- */
.sidebar-account { display: flex; align-items: center; gap: .5rem; margin-bottom: .25rem; padding-left: .6rem; }
.sidebar-account-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg); font-size: .875rem; font-weight: 500; text-decoration: none;
}
.sidebar-account form { margin: 0; }

.login-theme { position: fixed; top: 1rem; right: 1rem; }

/* ---- loratt 训练管理后台新增 ---- */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); color: var(--fg-muted); }
.badge-running { color: var(--accent); border-color: var(--accent); }
.badge-succeeded { color: var(--accent); }
.badge-failed, .badge-lost { color: var(--danger); border-color: var(--danger); }
.warn { color: var(--danger); }
pre.code { white-space: pre-wrap; word-break: break-word; font-size: .8rem; max-height: 70vh; overflow: auto; margin: 0; }
pre.log { max-height: 60vh; }
.markdown { overflow-x: auto; }
.markdown table { font-size: .85rem; }
.markdown pre { white-space: pre-wrap; }
.job-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.job-head p, .job-head form { margin: 0; }
.job-head button { margin: 0; }
svg.spark { width: 100%; max-width: 40rem; height: 6rem; color: var(--accent); }
