:root {
  --navy-950: #0b1f33;
  --navy-900: #102a43;
  --navy-700: #2b4c6f;
  --ink: #152536;
  --muted: #66788a;
  --line: #d9e3ec;
  --surface: #ffffff;
  --canvas: #f3f7fa;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --amber: #d97706;
  --coral: #dc5a4f;
  --shadow: 0 16px 42px rgba(16, 42, 67, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #2dd4bf;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, .14);
}

.btn {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 750;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-primary { color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(13, 148, 136, .2); }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { color: var(--navy-900); background: #e8f0f6; border-color: #cfdae5; }
.btn-warning { color: #fff; background: var(--amber); box-shadow: 0 8px 18px rgba(217, 119, 6, .18); }
.btn-ghost { color: var(--navy-700); background: transparent; border-color: var(--line); }
.btn-small { min-height: 36px; padding: 0 13px; font-size: 13px; }
.btn-block { width: 100%; }

.login-page { background: var(--navy-950); }
.login-shell {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(390px, .95fr);
  min-height: 100vh;
}
.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(52px, 8vw, 120px);
  color: #fff;
  background:
    linear-gradient(145deg, rgba(13, 148, 136, .19), transparent 42%),
    linear-gradient(20deg, #0b1f33, #163c59);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 28px;
  color: #fff;
  background: var(--teal);
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 20px;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(0,0,0,.18);
}
.brand-mark-small { width: 42px; height: 42px; margin: 0; border-radius: 13px; font-size: 18px; }
.login-brand h1 { max-width: 650px; margin: 8px 0 18px; font-size: clamp(40px, 5vw, 70px); line-height: 1.13; letter-spacing: -.04em; }
.brand-copy { max-width: 560px; color: #bed0df; font-size: 17px; line-height: 1.85; }
.brand-features { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.brand-features span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; color: #d7e4ed; font-size: 13px; }
.login-panel { display: grid; place-items: center; padding: 30px; background: #eef4f7; }
.login-card { width: min(440px, 100%); padding: 42px; background: #fff; border: 1px solid #d9e3ec; border-radius: 24px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0; font-size: 30px; }
.mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 34px; font-weight: 800; }
.login-form { display: grid; gap: 18px; margin-top: 30px; }
.login-form label, .form-field { display: grid; gap: 8px; color: var(--navy-700); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfdbe5;
  border-radius: 11px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(13,148,136,.1); }
.alert { margin-top: 20px; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert-error { color: #9f2d26; background: #fff0ee; border: 1px solid #ffd2cd; }
.security-note { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.simple-login-page {
  display: grid;
  min-height: 100vh;
  margin: 0;
  place-items: center;
  padding: 24px;
  background: #eef3f6;
}
.simple-login-shell {
  width: min(400px, 100%);
}
.simple-login-card {
  padding: 38px;
  background: #fff;
  border: 1px solid #dbe4eb;
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(16, 42, 67, .09);
}
.simple-brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 24px;
  color: #fff;
  background: var(--navy-900);
  border-radius: 14px;
  font-size: 20px;
  font-weight: 900;
}
.simple-login-card h1 {
  margin: 0;
  color: var(--navy-950);
  font-size: 28px;
  letter-spacing: -.025em;
}
.simple-login-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.simple-login-card .login-form {
  margin-top: 28px;
}
.simple-login-note {
  margin: 22px 0 0;
  color: #8a99a7;
  text-align: center;
  font-size: 12px;
}
@media (max-width: 520px) {
  .simple-login-page { padding: 16px; background: #fff; }
  .simple-login-card { padding: 28px 22px; border: 0; box-shadow: none; }
}

.topbar { position: sticky; top: 0; z-index: 20; color: #fff; background: rgba(11,31,51,.97); border-bottom: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(12px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; width: min(1240px, calc(100% - 36px)); min-height: 72px; margin: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: #9fb4c6; font-size: 11px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.server-state { color: #c6d8e5; font-size: 12px; }
.admin-name { padding: 7px 10px; background: rgba(255,255,255,.08); border-radius: 9px; font-size: 13px; }
.topbar .btn-ghost { color: #dbe8f0; border-color: rgba(255,255,255,.17); }

.page { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 60px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.hero-row h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.035em; }
.hero-row p:last-child { margin-bottom: 0; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric {
  position: relative;
  min-height: 152px;
  padding: 22px;
  overflow: hidden;
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric::after { content: ""; position: absolute; right: -26px; bottom: -42px; width: 120px; height: 120px; border: 22px solid rgba(255,255,255,.11); border-radius: 50%; }
.metric-navy { background: #173d5e; }
.metric-teal { background: #0f766e; }
.metric-amber { background: #b7660b; }
.metric-coral { background: #b94b43; }
.metric-label { display: block; color: rgba(255,255,255,.75); font-size: 13px; }
.metric strong { display: block; margin: 15px 0 9px; font-size: 31px; line-height: 1; }
.metric small { color: rgba(255,255,255,.72); }

.workspace { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(16,42,67,.05); }
.logs-panel { margin-top: 24px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: 23px; }
.search-box { display: grid; grid-template-columns: auto minmax(180px, 310px) auto; align-items: center; gap: 8px; min-width: min(100%, 420px); padding-left: 13px; background: #f7fafc; border: 1px solid var(--line); border-radius: 13px; }
.search-box > span { color: var(--muted); font-size: 22px; }
.search-box input { min-height: 42px; padding-left: 0; background: transparent; border: 0; box-shadow: none; }
.search-box .btn { margin-right: 3px; }
.batch-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -5px 0 18px; padding: 11px 13px; background: #f7fafc; border: 1px solid var(--line); border-radius: 13px; }
.batch-toolbar > div { display: grid; gap: 3px; }
.batch-toolbar > div > strong { color: var(--navy-900); font-size: 13px; }
.batch-toolbar > div > span { color: var(--muted); font-size: 12px; }
.users-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.user-card { padding: 19px; border: 1px solid var(--line); border-radius: 15px; background: #fff; transition: transform .15s, border .15s, box-shadow .15s; }
.user-card:hover { transform: translateY(-2px); border-color: #b8cbd9; box-shadow: 0 12px 26px rgba(16,42,67,.08); }
.user-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.user-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; color: #fff; background: var(--navy-700); border-radius: 12px; font-weight: 900; }
.user-title { min-width: 0; flex: 1; }
.user-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.user-title small { color: var(--muted); }
.balance-block { margin: 20px 0 16px; }
.balance-block span { display: block; color: var(--muted); font-size: 12px; }
.balance-block strong { display: block; margin-top: 6px; font-size: 26px; letter-spacing: -.03em; }
.balance-negative { color: var(--coral); }
.user-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 18px; }
.meta-cell { padding: 10px; background: #f5f8fa; border-radius: 10px; }
.meta-cell span, .meta-cell strong { display: block; }
.meta-cell span { color: var(--muted); font-size: 11px; }
.meta-cell strong { margin-top: 4px; font-size: 13px; }
.expiry-danger { color: var(--coral); }
.user-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.empty-state { display: grid; place-items: center; min-height: 220px; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.loading-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.loading-grid span { height: 270px; border-radius: 15px; background: linear-gradient(90deg,#eef3f6 25%,#f9fbfc 40%,#eef3f6 65%); background-size: 400% 100%; animation: shimmer 1.25s infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; color: var(--muted); font-size: 13px; }

.logs-list { display: grid; gap: 2px; }
.log-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid #edf1f4; }
.log-row:last-child { border-bottom: 0; }
.log-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: #e8f7f5; color: var(--teal-dark); font-weight: 900; }
.log-icon.expiry { color: var(--amber); background: #fff4df; }
.log-icon.deduction { color: var(--coral); background: #fff0ee; }
.log-icon.credential { color: #3157a4; background: #edf2ff; }
.log-main strong, .log-main span { display: block; }
.log-main span, .log-time { color: var(--muted); font-size: 12px; }
.log-time { text-align: right; }

.modal { width: min(520px, calc(100% - 24px)); padding: 0; border: 0; border-radius: 20px; background: transparent; box-shadow: var(--shadow); }
.modal-wide { width: min(780px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(7, 22, 36, .64); backdrop-filter: blur(4px); }
.modal-card { padding: 24px; background: #fff; border-radius: 20px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.modal-header h2 { margin: 0 0 4px; font-size: 23px; }
.modal-header p:last-child { margin: 0; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--muted); background: #f0f4f7; border: 0; border-radius: 10px; font-size: 24px; }
.balance-preview { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; padding: 14px 16px; color: #fff; background: var(--navy-900); border-radius: 13px; }
.balance-preview span { color: #bfd0dc; font-size: 12px; }
.balance-preview strong { font-size: 21px; }
.form-field { margin-top: 15px; }
.money-input { display: flex; align-items: center; border: 1px solid #cfdbe5; border-radius: 11px; overflow: hidden; }
.money-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(13,148,136,.1); }
.money-input b { padding-left: 14px; color: var(--teal-dark); font-size: 18px; }
.money-input input { border: 0; box-shadow: none; font-size: 20px; font-weight: 800; }
.quick-amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 9px; }
.quick-amounts button { min-height: 34px; color: var(--teal-dark); background: #e9f8f6; border: 1px solid #c8ebe6; border-radius: 9px; font-size: 12px; font-weight: 700; }
.quick-amounts .deduction { color: #a43d36; background: #fff0ee; border-color: #f2c9c5; }
.field-help { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.5; }
.credential-notice { padding: 12px 14px; color: #6f5200; background: #fff8df; border: 1px solid #f2dfa2; border-radius: 11px; font-size: 12px; line-height: 1.6; }
.credential-full-button { width: 100%; margin-top: 12px; }
.credential-result { margin-top: 12px; padding: 13px; background: #f2f7fb; border: 1px solid #d5e2eb; border-radius: 12px; }
.credential-result > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.credential-secret { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.credential-secret input { min-width: 0; color: var(--navy-900); background: #fff; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 800; }
.credential-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 2px; color: var(--muted); font-size: 12px; }
.credential-divider::before, .credential-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.transaction-modal { padding-bottom: 18px; }
.transaction-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.transaction-tabs { display: flex; gap: 5px; padding: 4px; background: #edf3f6; border-radius: 11px; }
.transaction-tabs button { min-height: 34px; padding: 0 12px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; font-size: 12px; font-weight: 700; }
.transaction-tabs button.active { color: #fff; background: var(--navy-900); }
.transaction-total { text-align: right; }
.transaction-total span, .transaction-total strong { display: block; }
.transaction-total span { color: var(--muted); font-size: 11px; }
.transaction-total strong { margin-top: 2px; color: var(--navy-900); font-size: 19px; }
.transaction-list { max-height: 490px; overflow-y: auto; border-top: 1px solid var(--line); }
.transaction-row { display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 15px 4px; border-bottom: 1px solid #e8eef2; }
.transaction-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 12px; font-weight: 900; }
.transaction-icon.expense { color: #a43d36; background: #fff0ee; }
.transaction-icon.income { color: var(--teal-dark); background: #e9f8f6; }
.transaction-title { display: flex; justify-content: space-between; gap: 16px; }
.transaction-title strong { overflow-wrap: anywhere; color: var(--ink); font-size: 14px; }
.transaction-title b { flex: 0 0 auto; font-size: 15px; }
.amount-expense { color: var(--coral); }
.amount-income { color: var(--teal-dark); }
.transaction-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; color: var(--muted); font-size: 11px; }
.transaction-breakdown { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.transaction-breakdown span { padding: 3px 7px; color: #546b7e; background: #f2f6f8; border-radius: 6px; font-size: 10px; }
.transaction-loading,.transaction-empty,.transaction-error { padding: 45px 10px; color: var(--muted); text-align: center; }
.transaction-error { color: var(--coral); }
.transaction-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 16px; color: var(--muted); font-size: 12px; }
.shop-summary { max-height: 150px; margin-top: 15px; overflow: auto; background: #f7f9fb; border-radius: 11px; }
.shop-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid #e7edf2; font-size: 12px; }
.shop-line small { color: var(--muted); }
.shop-line:last-child { border-bottom: 0; }
.batch-warning { padding: 12px 14px; color: #8b4d05; background: #fff7e8; border: 1px solid #f7d69c; border-radius: 11px; font-size: 13px; line-height: 1.6; }
.batch-impact { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; padding: 14px; color: var(--navy-900); background: #f4f7fa; border-radius: 11px; font-size: 13px; }
.batch-impact span { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 100; max-width: min(390px, calc(100% - 40px)); padding: 13px 17px; color: #fff; background: var(--navy-900); border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(14px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a83d35; }

@media (max-width: 980px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .users-grid, .loading-grid { grid-template-columns: repeat(2, 1fr); }
  .login-shell { grid-template-columns: .85fr 1.15fr; }
  .login-brand { padding: 50px; }
}

@media (max-width: 720px) {
  .login-shell { display: block; min-height: 100vh; background: #eef4f7; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 20px; }
  .login-card { padding: 28px 22px; border-radius: 20px; }
  .mobile-brand { display: flex; }
  .topbar-inner, .page { width: min(100% - 24px, 1240px); }
  .topbar-inner { min-height: 64px; }
  .brand small, .server-state, .admin-name { display: none; }
  .page { padding-top: 24px; }
  .hero-row { align-items: flex-start; }
  .hero-row .muted { font-size: 13px; line-height: 1.6; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { min-height: 126px; padding: 17px; }
  .metric strong { font-size: 24px; }
  .workspace { padding: 17px; border-radius: 15px; }
  .section-heading { display: block; }
  .search-box { width: 100%; margin-top: 16px; grid-template-columns: auto 1fr auto; }
  .batch-toolbar { align-items: stretch; flex-direction: column; }
  .batch-toolbar > .btn { width: 100%; }
  .users-grid, .loading-grid { grid-template-columns: 1fr; }
  .loading-grid span { height: 250px; }
  .log-row { grid-template-columns: 36px 1fr; }
  .log-time { grid-column: 2; text-align: left; }
  .modal { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
  .modal-card { padding: 20px; }
  .transaction-toolbar { align-items: stretch; flex-direction: column; }
  .transaction-tabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .transaction-tabs button { padding-inline: 6px; }
  .transaction-total { text-align: left; }
  .transaction-list { max-height: 52vh; }
}

@media (max-width: 430px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 118px; padding: 15px; }
  .metric-label, .metric small { font-size: 11px; }
  .metric strong { margin-top: 12px; font-size: 21px; }
  .hero-row { display: block; }
  .hero-row .btn { width: 100%; margin-top: 16px; }
  .user-actions { grid-template-columns: 1fr; }
  .quick-amounts { grid-template-columns: repeat(2, 1fr); }
  .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
