:root {
  --ink: #191a17;
  --ink-soft: #5d625b;
  --paper: #f4f1e8;
  --sheet: #fffdf7;
  --line: #c9c4b6;
  --line-dark: #8d8c83;
  --green: #16785c;
  --green-soft: #e4f2ec;
  --red: #e44d3a;
  --red-soft: #f8e4df;
  --yellow: #e7bd43;
  --yellow-soft: #f8efcc;
  --blue: #2f638a;
  --sidebar: 236px;
  --topbar: 64px;
  --radius: 6px;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-width: 280px;
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(25,26,23,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25,26,23,.025) 1px, transparent 1px);
  background-size: 24px 24px;
  font-size: 14px;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(22,120,92,.25);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 1.1fr) minmax(340px, .9fr);
  background: var(--ink);
}
.login-mark {
  min-width: 0;
  padding: clamp(40px, 8vw, 112px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f4f1e8;
  position: relative;
  overflow: hidden;
}
.login-mark::before {
  content: "";
  position: absolute;
  inset: 38px;
  border: 1px solid rgba(255,255,255,.16);
  pointer-events: none;
}
.login-mark::after {
  content: "档";
  position: absolute;
  right: -4vw;
  bottom: -12vw;
  font-family: "STSong", "SimSun", serif;
  font-size: clamp(240px, 34vw, 560px);
  line-height: 1;
  color: rgba(255,255,255,.035);
}
.login-mark span { font: 700 12px/1 monospace; letter-spacing: 2px; z-index: 1; }
.login-mark b {
  max-width: 600px;
  font-family: "STSong", "SimSun", serif;
  font-size: clamp(52px, 8vw, 116px);
  line-height: .96;
  letter-spacing: 0;
  z-index: 1;
}
.login-mark small { font: 12px/1 monospace; color: #a7aaa4; z-index: 1; }
.login-panel {
  align-self: center;
  width: min(440px, calc(100% - 56px));
  margin: auto;
  padding: 40px;
  background: var(--sheet);
  border-top: 7px solid var(--green);
  box-shadow: 14px 14px 0 rgba(0,0,0,.18);
}
.record-label, .eyebrow, .dialog-mark {
  display: inline-block;
  padding: 5px 8px;
  border: 1px solid currentColor;
  font: 700 10px/1 monospace;
  letter-spacing: 1px;
  color: var(--green);
}
.login-panel h1 { margin: 30px 0 6px; font: 700 32px/1.2 "STSong", "SimSun", serif; }
.login-panel > p { margin: 0 0 28px; color: var(--ink-soft); }
label { display: grid; gap: 7px; margin: 16px 0; font-weight: 700; }
input, textarea, select {
  min-width: 0;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  background: #fff;
}
textarea { resize: vertical; }
.form-error { min-height: 20px; color: var(--red); font-size: 12px; }
.security-note { display: block; margin-top: 18px; text-align: center; color: var(--ink-soft); }

.button {
  min-height: 38px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  font-weight: 700;
  background: var(--sheet);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 3px 3px 0 rgba(25,26,23,.12); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }
.button-wide { width: 100%; justify-content: space-between; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-danger { color: #fff; background: var(--red); border-color: var(--red); }
.button-secondary { background: #fff; }
.button-quiet { color: var(--green); border-color: var(--green); }
.button-small { min-height: 30px; padding: 5px 10px; font-size: 12px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  color: #e9e6dc;
  background: var(--ink);
  border-right: 1px solid #000;
}
.brand { padding: 24px 20px 20px; border-bottom: 1px solid #3b3d38; }
.brand-code { display: block; margin-bottom: 12px; color: var(--yellow); font: 700 10px/1 monospace; letter-spacing: 1.5px; }
.brand strong { display: block; font: 700 18px/1.3 "STSong", "SimSun", serif; }
.brand small { color: #8f938a; }
.main-nav { min-height: 0; padding: 14px 10px; display: grid; gap: 3px; overflow-y: auto; }
.nav-item {
  min-width: 0;
  height: 43px;
  padding: 0 10px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: #b6b9b2;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  text-align: left;
}
.nav-item i { font: 10px/1 monospace; color: #6f746b; font-style: normal; }
.nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { color: #fff; border-color: #454840; }
.nav-item.active { color: var(--ink); background: var(--paper); border-color: var(--paper); font-weight: 700; }
.nav-item.active i { color: var(--red); }
.sidebar-footer { margin-top: auto; padding: 17px 20px; border-top: 1px solid #3b3d38; }
.sidebar-footer div { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.sidebar-footer small { display: block; margin-top: 6px; color: #777b73; font: 10px/1 monospace; }
.signal { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #31b987; box-shadow: 0 0 0 3px rgba(49,185,135,.13); }

.topbar {
  position: fixed;
  z-index: 15;
  top: 0;
  left: var(--sidebar);
  right: 0;
  height: var(--topbar);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,253,247,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.breadcrumb { min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.breadcrumb span { color: var(--ink-soft); font: 10px/1 monospace; white-space: nowrap; }
.breadcrumb b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { min-width: 0; margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  font-size: 18px;
}
.menu-toggle { display: none; }
.environment { padding: 7px 9px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); font: 700 10px/1 monospace; }
.profile-button {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
}
.profile-button > span { width: 30px; height: 30px; display: grid; place-items: center; color: #fff; background: var(--green); font: 700 11px/1 monospace; }
.profile-button b { white-space: nowrap; }
.profile-button i { font-style: normal; color: var(--ink-soft); }

.workspace {
  min-width: 0;
  margin-left: var(--sidebar);
  padding: calc(var(--topbar) + 24px) 24px 48px;
}
.page-head {
  min-width: 0;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}
.page-head h1 { margin: 9px 0 5px; font: 700 clamp(25px, 3vw, 38px)/1.1 "STSong", "SimSun", serif; }
.page-head p { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; }
.page-actions { flex: 0 0 auto; display: flex; gap: 8px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line-dark);
  background: var(--sheet);
}
.metric { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric header { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-size: 12px; }
.metric strong { display: block; margin: 11px 0 6px; font: 700 clamp(25px, 3vw, 37px)/1 monospace; overflow-wrap: anywhere; }
.metric small { color: var(--ink-soft); }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

.grid { min-width: 0; margin-top: 16px; display: grid; gap: 16px; }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); }
.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel {
  min-width: 0;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-head {
  min-width: 0;
  min-height: 54px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { min-width: 0; margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.panel-head small { color: var(--ink-soft); }
.panel-body { min-width: 0; padding: 15px; }
.panel-flush .panel-body { padding: 0; }
.panel-tools { display: flex; align-items: center; gap: 7px; }

.status {
  max-width: 100%;
  padding: 3px 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 99px;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.status-live, .status-success { color: var(--green); background: var(--green-soft); }
.status-draft, .status-warning { color: #816313; background: var(--yellow-soft); }
.status-failed { color: var(--red); background: var(--red-soft); }
.status-neutral { color: var(--ink-soft); background: #ecebe6; }

.filter-bar {
  min-width: 0;
  padding: 11px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #f8f6ef;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 126px; max-width: 230px; padding: 7px 9px; }
.filter-bar .search { flex: 1 1 200px; max-width: none; }
.table-wrap { min-width: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { min-width: 0; padding: 11px 13px; border-bottom: 1px solid #dfdbcf; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
th { color: var(--ink-soft); background: #f8f6ef; font-size: 11px; white-space: nowrap; }
td { font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcfaf3; }
.cell-main { min-width: 0; }
.cell-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-main small { display: block; margin-top: 3px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-actions { display: flex; gap: 5px; justify-content: flex-end; }
.text-button { padding: 2px 3px; border: 0; color: var(--green); background: transparent; font-weight: 700; font-size: 12px; }

.chart {
  height: 232px;
  padding: 16px 8px 3px;
  display: flex;
  align-items: end;
  gap: clamp(5px, 1.4vw, 14px);
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to top, rgba(25,26,23,.07) 1px, transparent 1px);
  background-size: 100% 25%;
}
.bar-group { min-width: 0; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 7px; }
.bar { width: min(28px, 70%); min-height: 3px; background: var(--green); border-radius: 2px 2px 0 0; transition: height .4s ease; }
.bar-group:nth-child(3n) .bar { background: var(--yellow); }
.bar-group span { width: 100%; color: var(--ink-soft); font: 9px/1 monospace; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel { display: grid; gap: 9px; }
.funnel-row { min-width: 0; display: grid; grid-template-columns: 72px minmax(0, 1fr) 52px; align-items: center; gap: 8px; }
.funnel-row span { font-size: 12px; }
.funnel-track { min-width: 0; height: 16px; background: #ebe8df; }
.funnel-fill { height: 100%; background: var(--green); }
.funnel-row b { text-align: right; font: 700 11px/1 monospace; }

.list { display: grid; }
.list-item {
  min-width: 0;
  padding: 13px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item b, .list-item span { min-width: 0; overflow-wrap: anywhere; }
.list-item small { display: block; margin-top: 3px; color: var(--ink-soft); }
.timeline { position: relative; display: grid; gap: 0; }
.timeline-item { position: relative; padding: 4px 0 18px 26px; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.timeline-item::after { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline-item:last-child::after { display: none; }
.timeline-item b { display: block; }
.timeline-item small { color: var(--ink-soft); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.switch-row { min-width: 0; padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.switch-row b { display: block; overflow-wrap: anywhere; }
.switch-row small { color: var(--ink-soft); }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #c8c9c4; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }

.preview-card {
  max-width: 340px;
  margin: 4px auto;
  padding: 17px;
  background: #fff8e5;
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
}
.preview-card .tape { display: inline-block; margin: -29px 0 14px; padding: 5px 10px; background: var(--yellow); border: 1px solid var(--ink); font: 700 10px/1 monospace; }
.preview-card h3 { margin: 7px 0 12px; font: 700 24px/1.2 "STSong", "SimSun", serif; overflow-wrap: anywhere; }
.preview-card p { line-height: 1.7; overflow-wrap: anywhere; }
.preview-options { display: grid; gap: 7px; }
.preview-options span { padding: 8px; background: #fff; border: 1px solid var(--line-dark); overflow-wrap: anywhere; }

.state-view {
  min-height: 280px;
  padding: 50px 20px;
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--sheet);
  border: 1px solid var(--line);
}
.state-view > div { max-width: 420px; }
.state-view h2 { margin: 14px 0 8px; }
.state-view p { color: var(--ink-soft); overflow-wrap: anywhere; }
.state-icon { margin: auto; width: 42px; height: 42px; display: grid; place-items: center; border: 2px solid currentColor; font: 700 20px/1 monospace; }
.state-loading .state-icon { border-radius: 50%; border-right-color: transparent; animation: spin .8s linear infinite; }
.state-error .state-icon { color: var(--red); }
.state-empty .state-icon { color: var(--ink-soft); }
.skeleton { overflow: hidden; position: relative; background: #e5e1d7; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: shimmer 1.2s infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }

.confirm-dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--sheet); box-shadow: 12px 12px 0 rgba(0,0,0,.28); }
.confirm-dialog::backdrop { background: rgba(14,15,13,.64); backdrop-filter: blur(2px); }
.confirm-dialog form { padding: 24px; }
.confirm-dialog h2 { margin: 22px 0 8px; font: 700 24px/1.2 "STSong", "SimSun", serif; }
.confirm-dialog p { color: var(--ink-soft); line-height: 1.6; overflow-wrap: anywhere; }
.confirm-dialog textarea.editor-json {
  min-height: 360px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 2;
  white-space: pre;
}
.dialog-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 8px; }
.toast-region { position: fixed; z-index: 50; right: 18px; bottom: 18px; width: min(360px, calc(100% - 36px)); display: grid; gap: 8px; }
.toast { padding: 12px 14px; color: #fff; background: var(--ink); border-left: 5px solid var(--green); box-shadow: 5px 5px 0 rgba(0,0,0,.2); animation: toast-in .2s ease-out; overflow-wrap: anywhere; }
.toast.error { border-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1060px) {
  :root { --sidebar: 210px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --topbar: 56px; }
  .login-view { grid-template-columns: 1fr; }
  .login-mark { min-height: 210px; padding: 44px 36px; }
  .login-mark::before { inset: 18px; }
  .login-mark b { font-size: 48px; }
  .login-panel { width: min(100% - 28px, 440px); margin: -24px auto 28px; padding: 27px 22px; z-index: 2; box-shadow: 7px 7px 0 rgba(0,0,0,.18); }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; padding: 0 12px; }
  .menu-toggle { display: inline-grid; }
  .environment, .profile-button b, .profile-button i { display: none; }
  .profile-button { grid-template-columns: 30px; }
  .workspace { margin-left: 0; padding: calc(var(--topbar) + 16px) 12px 30px; }
  .page-head { align-items: start; }
  .page-actions { max-width: 46%; flex-wrap: wrap; justify-content: flex-end; }
  .grid-even, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .filter-bar > * { flex: 1 1 130px; max-width: none !important; }
  th, td { padding: 9px 10px; }
  table { min-width: 650px; }
  .chart { gap: 4px; }
}

@media (max-width: 440px) {
  .breadcrumb span { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .page-head { display: grid; }
  .page-actions { max-width: none; justify-content: start; }
  .page-actions .button { flex: 1 1 auto; }
  .panel-head { align-items: flex-start; }
  .panel-tools { flex-wrap: wrap; justify-content: flex-end; }
  .funnel-row { grid-template-columns: 58px minmax(0, 1fr) 46px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
