:root {
  --sea: #0b82bd;
  --sea-bright: #22b4e8;
  --sea-dark: #07577d;
  --deep: #052f46;
  --ink: #163743;
  --muted: #718994;
  --cream: #fff9ec;
  --sand: #f1e3ca;
  --gold: #e9aa3e;
  --gold-bright: #ffd36e;
  --gold-dark: #a96b12;
  --mint: #e1f4ee;
  --line: #e4ded2;
  --danger: #c25245;
  --white: #fff;
  --shadow: 0 24px 60px rgba(8, 55, 76, .16);
  --shadow-sm: 0 10px 28px rgba(8, 55, 76, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 86% 4%, rgba(113, 211, 235, .28), transparent 26%),
    radial-gradient(circle at 4% 92%, rgba(244, 200, 112, .16), transparent 25%),
    #edf6f8;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #35b3e6; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--sea); }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .22em;
}

/* Login */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-sea {
  position: relative;
  width: min(1080px, 100%);
  min-height: min(720px, calc(100vh - 48px));
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 34px;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, .34), transparent 30%),
    radial-gradient(circle at 82% 78%, rgba(255, 226, 156, .26), transparent 32%),
    linear-gradient(145deg, #25b4e7 0%, #0b83be 44%, #064b6d 100%);
  box-shadow: var(--shadow);
}
.login-sea::before,
.login-sea::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .13);
}
.login-sea::before { width: 540px; height: 540px; right: -130px; top: -170px; }
.login-sea::after { width: 780px; height: 780px; left: -270px; bottom: -480px; }
.login-sea .bubble {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.login-card {
  position: relative;
  z-index: 1;
  width: min(400px, calc(100% - 40px));
  padding: 40px 34px 30px;
  border-radius: 28px;
  background: linear-gradient(180deg, #fffef9, #fff6e3);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 28px 70px rgba(3, 34, 50, .32), inset 0 0 0 5px rgba(255, 250, 235, .65);
  text-align: center;
}
.login-card::before { content: ""; position: absolute; top: 9px; right: 9px; bottom: 9px; left: 9px; border: 1px solid #ead7b3; border-radius: 21px; pointer-events: none; }
.brand-mark {
  width: 66px;
  height: 66px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 21px;
  background: linear-gradient(145deg, #fff3c8, #f0b64c);
  box-shadow: inset 0 2px rgba(255, 255, 255, .75), 0 10px 22px rgba(168, 104, 17, .24);
  position: relative;
  z-index: 1;
}
.brand-mark img { width: 42px; height: 38px; object-fit: contain; }
.brand-mark.small { width: 44px; height: 44px; margin: 0; border-radius: 14px; }
.brand-mark.small img { width: 28px; height: 25px; }
.login-card h1 { margin: 0; font-size: 29px; letter-spacing: .05em; color: #523515; }
.login-sub { margin: 7px 0 25px; color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.login-form { position: relative; z-index: 1; display: grid; gap: 15px; text-align: left; }
.login-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; color: #6b5436; }
.login-form input {
  width: 100%;
  height: 49px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.login-form input:focus { border-color: #55b5dc; box-shadow: 0 0 0 4px rgba(70, 171, 213, .14); }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.login-note { position: relative; z-index: 1; margin-top: 18px; color: #9a8a73; font-size: 11px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  transition: transform .14s, box-shadow .14s, background .14s, border-color .14s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  border-color: #df9c2f;
  background: linear-gradient(180deg, #ffdf8b, #edaa36);
  color: #5b3a09;
  box-shadow: inset 0 1px rgba(255, 255, 255, .7), 0 8px 18px rgba(181, 118, 20, .22);
}
.btn-sea { background: linear-gradient(180deg, #46c1f2, #087dca); color: #fff; box-shadow: 0 8px 18px rgba(6, 102, 164, .24); }
.btn-ghost { border-color: var(--line); background: #fffaf0; color: #6b5436; }
.btn-danger { border-color: #e7b9b1; background: #fff3f1; color: var(--danger); }
.btn-sm { height: 33px; padding: 0 11px; border-radius: 9px; font-size: 12px; }
.btn-block { width: 100%; height: 51px; margin-top: 4px; border-radius: 15px; font-size: 15px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--sea); font-weight: 700; }
.link-btn.danger { color: var(--danger); }

/* App shell */
.app-view { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 17px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background:
    radial-gradient(circle at 20% 0%, rgba(76, 194, 233, .4), transparent 32%),
    radial-gradient(circle at 100% 100%, rgba(255, 201, 91, .12), transparent 32%),
    linear-gradient(180deg, #075578, #063e59 68%, #042b3f);
  color: #eaf8ff;
  overflow: hidden;
}
.sidebar::after { content: ""; position: absolute; left: -60%; bottom: -180px; width: 460px; height: 460px; border-radius: 50%; border: 1px solid rgba(157, 224, 245, .12); pointer-events: none; }
.sidebar-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 2px 6px; }
.sidebar-brand strong { display: block; font-size: 15px; letter-spacing: .05em; }
.sidebar-brand span { display: block; margin-top: 3px; color: #9fc8d8; font-size: 11px; letter-spacing: .08em; }
.nav { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #a9cbd8;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  transition: background .18s, color .18s, transform .18s;
}
.nav-item span { width: 20px; color: #7fb6c9; text-align: center; font-size: 15px; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(74, 190, 231, .32), rgba(74, 190, 231, .1));
  border-color: rgba(144, 220, 246, .26);
  color: #fff;
  box-shadow: inset 3px 0 #6dd8f8, 0 8px 18px rgba(0, 20, 30, .12);
}
.nav-item.active span { color: #96e8ff; }
.sidebar-foot {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, .12);
  color: #b9d8e4;
  font-size: 12px;
}
.sidebar-foot .link-btn { color: #ffd98b; }

.main { min-width: 0; padding: 30px 34px 52px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 27px; color: #123847; letter-spacing: -.01em; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.banner {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid #f0d59b;
  border-radius: 13px;
  background: #fff8e2;
  color: #805a1c;
  font-size: 12px;
  box-shadow: 0 5px 16px rgba(176, 124, 29, .08);
}
.content { display: grid; gap: 18px; max-width: 1320px; }

/* Cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card {
  position: relative;
  overflow: hidden;
  padding: 19px 18px 17px;
  border: 1px solid #e6e0d5;
  border-radius: 19px;
  background: linear-gradient(160deg, #fffdf8, #fff7e8);
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(8, 55, 76, .12); }
.stat-card::before { content: ""; position: absolute; top: 0; right: 17px; left: 17px; height: 2px; border-radius: 0 0 4px 4px; background: #e9aa3e; opacity: .65; }
.stat-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -40px;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(234, 170, 62, .12);
}
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { margin-top: 8px; font-size: 31px; font-weight: 800; color: #123847; letter-spacing: -.03em; line-height: 1.15; }
.stat-hint { margin-top: 7px; color: #97a8ae; font-size: 11px; }
.stat-card.blue { background: linear-gradient(160deg, #f3fbff, #e2f4fd); }
.stat-card.blue::before { background: #2aa4da; }
.stat-card.blue::after { background: rgba(37, 156, 211, .12); }
.stat-card.green { background: linear-gradient(160deg, #f4fcf8, #e0f4eb); }
.stat-card.green::before { background: #28a678; }
.stat-card.green::after { background: rgba(38, 160, 118, .12); }
.stat-card.gold { background: linear-gradient(160deg, #fffdf6, #ffefd0); }
.stat-card.gold::before { background: #e9aa3e; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; }
.panel {
  min-width: 0;
  border: 1px solid #e6e0d5;
  border-radius: 19px;
  background: #fffdf9;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 19px;
  border-bottom: 1px solid #eee7dc;
  background: linear-gradient(180deg, #fffdf9, #fffaf1);
}
.panel-head h2 { font-size: 15px; color: #1c4553; }
.panel-head p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.panel-body { padding: 17px 19px; }
.panel-body.flush { padding: 0; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap.compact table { min-width: 0; }
.table-wrap.compact th, .table-wrap.compact td { padding: 11px 12px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: 13px 15px; border-bottom: 1px solid #f1eadf; text-align: left; vertical-align: middle; font-size: 12px; }
th { color: #7f939b; font-weight: 700; background: #fbf7ef; white-space: nowrap; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #fffaf1; }
tr:last-child td { border-bottom: 0; }
.cell-main { font-weight: 700; color: #193e4c; }
.cell-sub { margin-top: 3px; color: #91a1a8; font-size: 10px; }
.cell-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; letter-spacing: .03em; color: #17546e; }
.cell-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: #dcf4e9; color: #0a8060; }
.badge-gold { background: #fff0cd; color: #946114; }
.badge-gray { background: #edf1f2; color: #6f848e; }
.badge-red { background: #fde9e6; color: #b4483c; }
.badge-blue { background: #e2f3fd; color: #16719b; }
.muted { color: var(--muted); }
.empty { padding: 42px 20px; text-align: center; color: #93a6ad; font-size: 12px; }
.empty .big { display: block; font-size: 26px; margin-bottom: 8px; opacity: .55; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 13px 17px; border-top: 1px solid #f0e9de; color: var(--muted); font-size: 11px; background: #fffdf9; }

/* Toolbar / forms */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar input, .toolbar select {
  height: 37px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
  outline: none;
  font-size: 12px;
}
.toolbar input:focus, .toolbar select:focus { border-color: #5cb9dd; box-shadow: 0 0 0 3px rgba(64, 171, 213, .12); }
.toolbar input.search { width: 230px; }
.form-grid { display: grid; gap: 15px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: #675237; }
.field input, .field select, .field textarea {
  width: 100%;
  height: 43px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fffdf8;
  outline: none;
  font-weight: 400;
  transition: border-color .18s, box-shadow .18s;
}
.field textarea { height: 88px; padding: 11px 13px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #5cb9dd; box-shadow: 0 0 0 3px rgba(64, 171, 213, .12); }
.field .hint { color: #98a8ad; font-size: 10px; font-weight: 400; line-height: 1.5; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.tier-setting { display: grid; gap: 8px; padding: 14px; border: 1px solid #eadfcb; border-radius: 13px; background: #fffaf0; }
.field-label { font-size: 12px; font-weight: 700; color: #675237; }
.tier-setting-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tier-setting-chip { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 62px; padding: 7px 9px; border: 1px solid #ead5ab; border-radius: 10px; background: #fffdf7; }
.tier-setting-chip b { color: #7c4f12; font-size: 15px; }
.tier-setting-chip small { color: #9a7a48; font-size: 9px; }
.tier-setting-chip.repeat { border-color: #8bd8bf; background: #f0fbf6; }
.tier-setting-chip.repeat small { color: #0d8b70; }
.tier-setting .hint { color: #8b9ba2; font-size: 10px; line-height: 1.5; }

/* Modal */
.modal-scrim {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 35, 50, .58);
  backdrop-filter: blur(4px);
}
.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  border-radius: 22px;
  background: #fffdf8;
  box-shadow: 0 34px 90px rgba(3, 28, 42, .4);
  border: 1px solid #fff5df;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 21px 23px 0; }
.modal-head h2 { font-size: 19px; color: #173f4d; }
.modal-head p { margin-top: 4px; color: var(--muted); font-size: 11px; }
.modal-close { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 50%; background: #fff8e9; color: #9a6a2d; font-size: 18px; line-height: 1; }
.modal-body { padding: 18px 23px 23px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 15px; }
.detail-stat { padding: 11px; border-radius: 11px; background: #f8f4ea; text-align: center; }
.detail-stat strong { display: block; font-size: 19px; color: #1a4655; }
.detail-stat span { color: var(--muted); font-size: 10px; }
.detail-list { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.detail-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; background: #fbf8f1; font-size: 11px; }
.detail-row span { color: var(--muted); }

/* Toast */
.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  min-width: 190px;
  max-width: min(430px, calc(100% - 40px));
  padding: 12px 17px;
  border-radius: 13px;
  background: rgba(10, 46, 62, .95);
  color: #fff;
  font-size: 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 10px 28px rgba(0, 20, 30, .25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(151, 58, 47, .97); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; gap: 14px; }
  .sidebar-brand { display: none; }
  .nav { flex-direction: row; overflow-x: auto; padding-bottom: 2px; }
  .nav-item { flex: none; width: auto; height: 38px; padding: 0 12px; }
  .nav-item:hover { transform: none; }
  .sidebar-foot { margin: 0; padding: 8px 0 0; border-top: 0; }
  .main { padding: 20px 16px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .form-grid.two { grid-template-columns: 1fr; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .login-sea { min-height: calc(100vh - 32px); border-radius: 26px; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 25px; }
  .toolbar input.search { width: 100%; }
  .toolbar { width: 100%; }
  .login-card { padding: 31px 22px 24px; }
  .login-sea { padding: 0; }
}
