/* 数据湖管理后台的视觉系统（framed-sheet）。
   外壳：侧栏与页面地面是同一块着色的框，内容区是一张白色的"纸"，纸与框之间只靠一级色阶区分，不用阴影。
   颜色只用于数据与状态；主操作用近黑色，不用品牌色铺满按钮。
   叠加在 Pico 之上：覆盖的变量写在 :root:root，特异性高于 Pico 的主题选择器。 */

:root:root {
  --font-sans: "IBM Plex Sans", Inter, system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB",
    "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --radius-card: 8px;
  --radius-control: 6px;
  --radius-sheet: 16px;
  --sheet-inset: 8px;
  --sidebar-w: 228px;
  --content-pad: 24px;
  --gap: 24px;
  --row-h: 48px;
  --control-h: 36px;

  --fs-title: 22px;
  --fs-section: 16px;
  --fs-body: 14px;
  --fs-small: 12px;

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 150ms;

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

/* 浅色（默认）：薄荷色的框，干净的白纸，青绿色只用在标识与数据上 */
:root:not([data-theme]),
:root[data-theme="light"] {
  color-scheme: light;
  --frame: #f3f6f5;        /* 侧栏与页面地面：淡薄荷 */
  --surface: #ffffff;      /* 内容纸面 */
  --raised: #f7f9f8;       /* 表头、悬停的浅面 */
  --active: #e6eeec;       /* 当前导航项、选中态 */
  --border: #dfe7e4;       /* 纸的边、卡片边 */
  --rule: #edf2f0;         /* 表格行线 */
  --control: #c3d0cc;      /* 输入框边 */
  --text: #1d2a28;
  --muted: #5b6b68;
  --faint: #66757a;        /* 占位与次要文字，白底 4.5:1 以上 */
  --primary: #34504c;      /* 主操作：深青绿填充、白字 */
  --primary-ink: #ffffff;
  --accent: #4f9a90;       /* 品牌色：数据与焦点 */
  --accent-strong: #3f7f77;/* 标识底色，保证白字对比度 */
  --positive: #2f7d5f;
  --negative: #d2433b;
  --warning: #9a5b08;
  --pill-positive-bg: #e1efe9; --pill-positive-ink: #24523f;
  --pill-negative-bg: #f8e6e4; --pill-negative-ink: #7d2c27;
  --pill-warning-bg: #f7f1e0;  --pill-warning-ink: #6b4e1a;
  --pill-neutral-bg: #eaefed;  --pill-neutral-ink: #3e4e4b;
  --pill-info-bg: #e2edf1;     --pill-info-ink: #2d5566;
  --focus: #4f9a90;
}

/* 深色：深青的地面，纸是更浅一级的青黑，强调色提亮 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --frame: #0a1715;
  --surface: #112220;
  --raised: #162b29;
  --active: #1d3835;
  --border: #21403c;
  --rule: #1a3330;
  --control: #33544f;
  --text: #e4f5f1;
  --muted: #a3c7c0;
  --faint: #94b8b0;
  --primary: #cfe3df;
  --primary-ink: #0a1715;
  --accent: #7fbfb4;
  --accent-strong: #7fbfb4;
  --positive: #4ad09a;
  --negative: #f2857c;
  --warning: #f5c04d;
  --pill-positive-bg: #1a2f2a; --pill-positive-ink: #8fd0b6;
  --pill-negative-bg: #36201f; --pill-negative-ink: #f7a09a;
  --pill-warning-bg: #332a14;  --pill-warning-ink: #f5c04d;
  --pill-neutral-bg: #203633;  --pill-neutral-ink: #c4dcd7;
  --pill-info-bg: #143140;     --pill-info-ink: #8fd6ea;
  --focus: #7fbfb4;
}

/* Pico 的变量覆盖（提高优先级） */
:root:root {
  --pico-background-color: var(--surface);
  --pico-color: var(--text);
  --pico-h1-color: var(--text);
  --pico-h2-color: var(--text);
  --pico-h3-color: var(--text);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--border);
  --pico-primary: var(--text);
  --pico-primary-background: var(--primary);
  --pico-primary-border: var(--primary);
  --pico-primary-hover-background: var(--text);
  --pico-primary-hover-border: var(--text);
  --pico-primary-focus: color-mix(in srgb, var(--focus) 35%, transparent);
  --pico-primary-inverse: var(--primary-ink);
  --pico-secondary-background: var(--surface);
  --pico-secondary-border: var(--control);
  --pico-secondary-hover-background: var(--raised);
  --pico-secondary-inverse: var(--text);
  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--border);
  --pico-card-sectioning-background-color: var(--raised);
  --pico-box-shadow: none;
  --pico-form-element-background-color: var(--surface);
  --pico-form-element-border-color: var(--control);
  --pico-form-element-color: var(--text);
  --pico-form-element-focus-color: var(--focus);
  --pico-table-border-color: var(--rule);
  --pico-ins-color: var(--positive);
  --pico-del-color: var(--negative);
}

a { color: var(--text); text-decoration: none; text-underline-offset: .2em; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

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

/* ---------- 外壳：着色的框 + 白色的纸 ---------- */
body { background: var(--frame); color: var(--text); font-size: var(--fs-body); }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--frame);
}

.topbar { display: none; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  background: var(--frame);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); text-decoration: none; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent-strong);
  color: #ffffff;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
}

.sidebar nav { display: block; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* Pico 对 nav 的默认排版（居中、两端对齐）在侧栏里要撤销 */
.sidebar nav ul { justify-content: flex-start; align-items: stretch; width: 100%; }
.sidebar nav li { width: 100%; }
.sidebar nav a { justify-content: flex-start; width: 100%; }
.sidebar nav ul { display: flex; flex-direction: column; gap: 2px; margin: 0 0 8px; padding: 0; }
.sidebar nav li { display: block; list-style: none; margin: 0; padding: 0; }

.nav-group {
  margin: 14px 0 4px;
  padding: 0 8px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--muted);
}

.sidebar nav li a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: var(--fs-body);
  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(--active); color: var(--text); text-decoration: none; }
.sidebar nav li a.nav-link[aria-current="page"] {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}
.sidebar nav li a.nav-link .icon { color: var(--faint); }
.sidebar nav li a.nav-link[aria-current="page"] .icon { color: var(--accent); }

.sidebar-foot {
  flex: none;
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-account { display: flex; align-items: center; gap: 6px; padding: 0 8px; }
.sidebar-account-name {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-size: var(--fs-body); font-weight: 500;
}
.sidebar-account form { margin: 0; }

.icon-btn.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-height: 34px;
  min-width: 34px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  box-shadow: none;
}
.icon-btn.icon-btn:hover { background: var(--active); color: var(--text); }

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

/* 内容区即"纸"：白色，1px 边，16px 圆角，与框之间只有 8px 的留白，没有阴影 */
.app-shell > .content {
  width: 100%;
  min-width: 0;
  margin: var(--sheet-inset) var(--sheet-inset) var(--sheet-inset) 0;
  padding: 28px 36px 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  min-height: calc(100vh - 2 * var(--sheet-inset));
}

.nav-backdrop { display: none; }

/* ---------- 页面标题与面板 ---------- */
.page-head { margin-bottom: 20px; display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { margin: 0; font-size: var(--fs-title); font-weight: 600; line-height: 1.25; color: var(--text); }
.page-head p { margin: 0; }
.eyebrow { font-size: var(--fs-small); color: var(--muted); }
.muted { color: var(--muted); }
.ok { color: var(--positive); }
.err { color: var(--negative); }
ul.err { list-style: none; padding-left: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}
.pill-running { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill-planned { background: var(--pill-info-bg); color: var(--pill-info-ink); }
.pill-paused { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.pill-failed { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }

.cards {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: var(--gap);
}

.panel {
  padding: 0 0 4px;
  margin-bottom: var(--gap);
  background: transparent;
  border: 0;
}
.panel h2 {
  font-size: var(--fs-section);
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
}
.panel h3 { font-size: var(--fs-body); font-weight: 600; margin: 20px 0 8px; color: var(--text); }
.panel form { margin-bottom: 0; }

/* 概览里的路线设置：一个带边的面，表单在里面 */
.cards > .panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.grid {
  display: grid;
  gap: 12px 16px;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  align-items: start;
}
.grid label { margin-bottom: 0; }

/* 表单：标签在上，输入 36px，字段之间 16px */
label { font-size: var(--fs-body); font-weight: 500; color: var(--text); margin-bottom: 14px; display: block; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  min-height: var(--control-h);
  margin-top: 6px;
  font-size: var(--fs-body);
  font-weight: 400;
  border-radius: var(--radius-control);
}
input::placeholder { color: var(--faint); }
input[aria-invalid="true"] { border-color: var(--negative); }
small.err { display: block; margin-top: 4px; font-size: var(--fs-small); }

button, [role="button"] {
  min-height: var(--control-h);
  font-size: var(--fs-body);
  font-weight: 500;
  border-radius: var(--radius-control);
}
/* 按钮不占满整行：只有在表单底部的主操作保持自然宽度 */
.panel form > button[type="submit"],
.panel form > .row > button,
.panel button { width: auto; margin-top: 4px; padding-inline: 16px; }
button.secondary, button.outline { padding-inline: 12px; min-height: 32px; }
button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--control); }
button.secondary:hover { background: var(--raised); }
button.outline { background: transparent; color: var(--negative); border: 1px solid var(--border); }
button.outline:hover { background: var(--pill-negative-bg); }
button:active { transform: translateY(1px); }

/* 表格：表头灰色、无底色，行线极淡，数字右对齐、等宽 */
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 36rem; margin-bottom: 0; font-size: var(--fs-body); }
.table-wrap thead th {
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border-bottom: 1px solid var(--rule);
  padding: 10px 12px;
  white-space: nowrap;
}
.table-wrap tbody td {
  height: var(--row-h);
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover td { background: var(--raised); }
.table-wrap td.num, .table-wrap th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap td.id, .table-wrap .mono { font-family: var(--font-mono); font-size: var(--fs-small); color: var(--muted); }
.table-wrap input, .table-wrap select { min-height: 32px; margin: 0; }
.table-wrap button { min-height: 32px; margin: 0; padding-inline: 12px; }
.table-wrap td:first-child, .table-wrap th:first-child { padding-left: 0; }
.table-wrap td:last-child, .table-wrap th:last-child { padding-right: 0; }
.table-wrap td.act, .table-wrap th.act { text-align: right; }

/* 概览的阶段列表：分隔线，不做卡片 */
.stage-list { list-style: none; padding-left: 0; margin: 0; }
.stage-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.stage-list li:last-child { border-bottom: 0; }
.stage-list a { font-weight: 500; }

/* 占位页与只读说明：窄行距、可读的行长 */
.panel p, .panel li { max-width: 72ch; }
.panel ul { padding-left: 20px; }

/* ---------- 窄屏：侧栏收起为抽屉，纸铺满 ---------- */
@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: 8px;
    height: 48px;
    padding: 0 12px;
    background: var(--frame);
  }
  .brand-compact { padding: 0; font-size: 14px; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(18rem, 85vw);
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
    border-right: 1px solid var(--border);
  }
  body.nav-open .sidebar { transform: translateX(0); }

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

  .app-shell > .content {
    margin: 0;
    padding: 20px 16px 40px;
    border: 0;
    border-radius: 0;
    min-height: 0;
  }
  .table-wrap table { min-width: 32rem; }
}

/* ---------- 登录页 ---------- */
.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
}
.login-card .brand { margin-bottom: 20px; padding: 0; }
.login-card h1 { font-size: var(--fs-title); font-weight: 600; margin: 0 0 20px; }
.login-card button[type="submit"] { width: 100%; margin-top: 8px; }
.login-card .note { font-size: var(--fs-small); margin-top: 16px; }
.login-theme { position: fixed; top: 12px; right: 12px; }

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.mono-label { font-family: var(--font-mono); font-size: var(--fs-small); font-weight: 500; letter-spacing: 0; }
