:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #697386;
  --line: #e6eaf0;
  --bg: #f4f7fb;
  --panel: #fff;
  --primary: #3157d5;
  --primary-dark: #2444b4;
  --danger: #c53b4b;
  --warning: #a76508;
  --success: #16784b;
  --shadow: 0 12px 35px rgba(24, 39, 75, .08);
  --font-display: Bahnschrift, "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-body: "Segoe UI Variable Text", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.55 var(--font-body);
}

h1, h2, .brand, .brand-mark { font-family: var(--font-display); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(49, 87, 213, .28);
  outline-offset: 2px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f8;
}

.login-card {
  width: min(420px, 100%);
  padding: 38px;
  border: 1px solid #fff;
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.brand-mark, .brand span {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.brand-mark {
  width: 54px;
  height: 54px;
  margin: auto;
  border-radius: 16px;
  font-size: 24px;
}

.login-card h1 { margin: 16px 0 4px; text-align: center; }
.login-card > p { margin: 0 0 24px; color: var(--muted); text-align: center; }
label { display: grid; gap: 7px; margin: 14px 0; color: #38445a; font-weight: 600; }

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cfd6e2;
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 87, 213, .12);
}

textarea { min-height: 88px; resize: vertical; }
.primary, .secondary, .danger, .table-action {
  padding: 9px 14px;
  border: 0;
  border-radius: 8px;
  font-weight: 650;
  transition: background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.primary { color: #fff; background: var(--primary); }
.primary:hover { background: var(--primary-dark); }
.secondary { color: #34435e; background: #e9eef7; }
.secondary:hover { background: #dce4f0; }
.danger { color: #fff; background: var(--danger); }
.danger:hover { background: #a92d3c; }
.login-card .primary { width: 100%; padding: 12px; }
.error { min-height: 20px; color: var(--danger); font-size: 13px; }

.captcha { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: end; }
.captcha button {
  height: 46px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.captcha img { width: 100%; height: 100%; object-fit: contain; }
.captcha label { margin: 0; }

.app { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; }
aside {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  color: #fff;
  background: #111a2e;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand span { width: 42px; height: 42px; border-radius: 12px; font-size: 19px; }
.brand strong, .brand small { display: block; }
.brand small { color: #96a2bb; }
nav { display: grid; gap: 5px; }
nav button, .logout {
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 8px;
  color: #b9c3d8;
  background: transparent;
  text-align: left;
}
nav button:hover, nav button.active { color: #fff; background: #253354; }
.logout {
  position: absolute;
  bottom: 20px;
  left: 16px;
  width: calc(100% - 32px);
  color: #eab5bc;
}

.workspace { min-width: 0; padding: 26px 30px; }
.workspace > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.workspace h1 { margin: 0; font-size: 24px; }
.workspace header p { margin: 3px 0 0; color: var(--muted); }
.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f2d58d;
  border-radius: 9px;
  color: #654304;
  background: #fff4d7;
}

.cards { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card, .panel {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: 0 3px 14px rgba(24, 39, 75, .04);
}
.card { padding: 18px; }
.card small { color: var(--muted); }
.card strong { display: block; margin-top: 5px; font-size: 24px; }
.panel { margin-bottom: 18px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: #566176; background: #f9fafc; font-size: 12px; }
tbody tr:hover { background: #f9fbff; }

.status { display: inline-block; padding: 3px 8px; border-radius: 999px; color: #526079; background: #edf1f7; font-size: 12px; }
.status.ok { color: var(--success); background: #e5f6ee; }
.status.warn { color: var(--warning); background: #fff2d7; }
.status.bad { color: var(--danger); background: #fdebed; }
.actions { display: flex; gap: 6px; }
.table-action { padding: 6px 9px; color: #2c4ebd; background: #e8edff; }
.table-action:hover { background: #d9e1fb; }
.table-action.danger { color: var(--danger); background: #fdebed; }
.table-action.danger:hover { background: #f8dce0; }
.empty, .loading { padding: 52px 20px; color: var(--muted); text-align: center; }

dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 15px;
  box-shadow: 0 24px 80px rgba(13, 25, 50, .28);
}
dialog::backdrop { background: rgba(12, 20, 36, .5); }
dialog form > header, dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
dialog form > header h2 { margin: 0; font-size: 18px; }
dialog form > header button { border: 0; color: var(--muted); background: none; font-size: 25px; }
#dialogFields { padding: 4px 20px; }
dialog footer { justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); border-bottom: 0; }
.money { font-variant-numeric: tabular-nums; font-weight: 650; }
.two-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.toolbar input { width: 180px; padding: 8px 10px; }
.login-secondary { width: 100%; margin-top: 10px; }

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

@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .two-panels { grid-template-columns: 1fr; }
  .app { grid-template-columns: 172px 1fr; }
  aside { padding: 18px 12px; }
  .brand { gap: 10px; padding: 0 4px 20px; }
  .brand span { flex: none; }
  nav button { padding-inline: 12px; font-size: 13px; }
  .logout { left: 12px; width: calc(100% - 24px); font-size: 13px; }
  .workspace { padding: 20px; }
}

@media (max-width: 640px) {
  .app { display: block; }
  aside { position: static; height: auto; padding: 10px; }
  .brand { display: none; }
  nav { display: flex; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: 0 0 auto; width: auto; min-height: 44px; font-size: 13px; white-space: nowrap; }
  .logout { position: static; width: auto; min-height: 44px; margin-top: 8px; font-size: 13px; }
  .workspace { padding: 16px; }
  .workspace > header { align-items: flex-start; }
  .cards { grid-template-columns: 1fr 1fr; gap: 9px; }
  .card { padding: 13px; }
  .card strong { font-size: 19px; }
  .captcha { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
  input, select, textarea, .primary, .secondary, .danger, .table-action { min-height: 44px; }
}
