/* 归码管理后台 — 蓝色 + 商务灰，原创品牌（非易HS/RuoYi） */
:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1e86fc;
  --brand-dark: #1565c0;
  --brand-soft: #e8f3ff;
  --brand-deep: #0b3d91;
  --sidebar: #0f1c24;
  --sidebar-2: #152833;
  --sidebar-hover: rgba(30, 134, 252, 0.15);
  --sidebar-active: #1e86fc;
  --accent: #1e86fc;
  --warn: #d97706;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.04);
  --font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  --sidebar-w: 220px;
  --top-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
a { color: var(--brand-dark); }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(30,134,252,.22), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(21,101,192,.14), transparent 45%),
    linear-gradient(160deg, #0b1a33 0%, #0d47a1 55%, #1e86fc 100%);
  padding: 1.5rem;
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem 2rem 1.75rem;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
.login-brand {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.5rem;
}
.login-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #3e95f9, #1e86fc);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem;
}
.login-brand h1 { margin: 0; font-size: 1.25rem; }
.login-brand p { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.login-form label { display: block; font-size: .82rem; color: var(--muted); margin: .85rem 0 .35rem; }
.login-form input {
  width: 100%; padding: .65rem .85rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  outline: none; background: #f8fafc;
}
.login-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }
.login-error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin-top: .5rem; }
.login-hint { margin-top: 1rem; font-size: .78rem; color: var(--muted); text-align: center; }

/* ===== Shell ===== */
#app-shell { display: none; height: 100vh; overflow: hidden; }
#app-shell.is-on { display: flex; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #cbd5e1; display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  height: var(--top-h); display: flex; align-items: center; gap: .6rem;
  padding: 0 1rem; border-bottom: 1px solid rgba(255,255,255,.06);
  font-weight: 700; color: #fff; font-size: .95rem; white-space: nowrap;
}
.sidebar-brand .mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, #3e95f9, #1e86fc);
  display: grid; place-items: center; font-size: .7rem; font-weight: 800;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0 1.5rem; }
.nav-group-title {
  padding: .65rem 1rem .3rem; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .06em;
  color: #64748b; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .55rem 1rem; margin: 1px .5rem;
  border-radius: 6px; cursor: pointer; color: #94a3b8;
  border: none; background: transparent; width: calc(100% - 1rem);
  text-align: left; font-size: .875rem; transition: .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .ico { width: 1.1em; opacity: .85; text-align: center; }
.nav-sub {
  padding-left: .25rem;
}
.nav-sub .nav-item { font-size: .82rem; padding: .45rem 1rem .45rem 1.85rem; }

.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  height: var(--top-h); background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; gap: 1rem; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.breadcrumb { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb strong { color: var(--ink); font-weight: 600; }
.btn-icon {
  border: none; background: transparent; cursor: pointer;
  padding: .35rem .5rem; border-radius: 6px; color: var(--muted);
}
.btn-icon:hover { background: var(--bg); color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.user-chip {
  display: flex; align-items: center; gap: .5rem;
  padding: .25rem .55rem; border-radius: 999px; background: var(--bg);
  font-size: .82rem;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: .7rem; font-weight: 700;
}
.content { flex: 1; overflow: auto; padding: 1rem 1.25rem 2rem; }

/* ===== Common UI ===== */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .9rem; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  font-size: .85rem; font-weight: 500; white-space: nowrap;
  transition: .15s; background: var(--surface); color: var(--ink);
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-sm { padding: .28rem .55rem; font-size: .78rem; }
.btn-link { background: none; border: none; color: var(--brand-dark); cursor: pointer; padding: 0 .25rem; font-size: .82rem; }
.btn-link.danger { color: var(--danger); }

.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.card-pad { padding: 1rem 1.15rem; }
.page-title { margin: 0 0 .85rem; font-size: 1.15rem; font-weight: 700; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  margin-bottom: .85rem;
}
.toolbar .spacer { flex: 1; min-width: .5rem; }
.search-input, .select-input {
  padding: .45rem .7rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; min-width: 160px;
  outline: none;
}
.search-input:focus, .select-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .82rem;
  min-width: 720px;
}
table.data th, table.data td {
  padding: .55rem .7rem; text-align: left;
  border-bottom: 1px solid var(--line); vertical-align: middle;
}
table.data th {
  background: #f8fafc; color: var(--muted); font-weight: 600;
  white-space: nowrap; position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--line);
}
table.data tr:hover td { background: #f8fffe; }
table.data td.ops { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .8rem; }
.tag {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
}
.tag-ok { background: #d1fae5; color: #065f46; }
.tag-off { background: #fee2e2; color: #991b1b; }
.tag-warn { background: #fef3c7; color: #92400e; }
.tag-info { background: #e0f2fe; color: #075985; }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .5rem; margin-top: .75rem; font-size: .82rem; color: var(--muted);
}
.pager-btns { display: flex; gap: .35rem; align-items: center; }

/* Stats */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .85rem; margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.stat-card .label { color: var(--muted); font-size: .8rem; }
.stat-card .value { font-size: 1.65rem; font-weight: 700; margin-top: .25rem; color: var(--brand-deep); }
.stat-card .sub { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

.dash-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem;
}
@media (max-width: 960px) {
  .dash-grid { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; box-shadow: 8px 0 32px rgba(0,0,0,.3); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .sidebar-backdrop.show { display: block; }
}

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  z-index: 100; display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: min(720px, 100%);
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.modal.wide { width: min(920px, 100%); }
.modal-hd {
  padding: .9rem 1.15rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700;
}
.modal-bd { padding: 1.1rem 1.15rem; overflow: auto; flex: 1; }
.modal-ft {
  padding: .75rem 1.15rem; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: .5rem;
}
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid var(--line);
  border-radius: var(--radius); outline: none; background: #f8fafc;
}
.form-field textarea { min-height: 72px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff;
}
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.empty {
  text-align: center; padding: 2.5rem 1rem; color: var(--muted);
}
.toast {
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 200;
  background: var(--ink); color: #fff; padding: .65rem 1rem;
  border-radius: 8px; font-size: .85rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px); transition: .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

.stub-box {
  padding: 2rem; text-align: center; color: var(--muted);
}
.stub-box h3 { color: var(--ink); margin: 0 0 .5rem; }

.hidden { display: none !important; }
.file-input-hidden { display: none; }

.list-tree { list-style: none; margin: 0; padding: 0; }
.list-tree li {
  padding: .55rem .75rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .75rem;
}
.list-tree li:hover { background: #f8fffe; }
.list-tree .ch-code {
  font-family: var(--mono); font-weight: 700; color: var(--brand-dark);
  min-width: 2.5rem;
}
