:root {
  --bg: #f3f6f4;
  --paper: #ffffff;
  --ink: #132019;
  --muted: #6d7c74;
  --line: #dce5df;
  --green: #0b7a53;
  --green-2: #075c40;
  --green-soft: #dff4ea;
  --amber: #b86c00;
  --red: #bb3c3c;
  --red-soft: #fbe7e7;
  --shadow: 0 22px 70px rgba(14, 45, 32, .12);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-page {
  background:
    radial-gradient(circle at 8% 10%, rgba(87, 196, 146, .28), transparent 34%),
    radial-gradient(circle at 90% 88%, rgba(22, 109, 78, .16), transparent 30%),
    #eef4f0;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-shell {
  width: min(1080px, 100%);
  min-height: 690px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .78fr);
  background: var(--paper);
  border: 1px solid rgba(17, 72, 50, .09);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.login-card { padding: clamp(32px, 5vw, 68px); display: flex; flex-direction: column; }
.brand { display: inline-flex; align-items: center; gap: 13px; width: fit-content; }
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(145deg, #0f9464, #07583d);
  font-weight: 900;
  letter-spacing: -.05em;
  box-shadow: 0 10px 25px rgba(11, 122, 83, .25);
}
.brand strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: .15em; }
.hero-copy { margin-top: 60px; max-width: 500px; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 850; letter-spacing: .18em; }
.hero-copy h1, .admin-login-card h1, .admin-header h1 { margin: 12px 0 0; font-size: clamp(34px, 4vw, 52px); line-height: 1.06; letter-spacing: -.055em; }
.hero-copy p { margin: 18px 0 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.login-form { display: grid; gap: 10px; margin-top: 38px; max-width: 500px; }
.login-form > label, .admin-login-card label { color: #394a41; font-size: 12px; font-weight: 800; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 70px; }
input, select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 0 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(11, 122, 83, .09); background: #fff; }
.input-wrap button {
  position: absolute; top: 7px; right: 7px; height: 34px; border: 0; border-radius: 8px; background: var(--green-soft); color: var(--green-2); padding: 0 12px; font-size: 11px; font-weight: 800;
}
.primary-button, .secondary-button, .danger-button, .text-button {
  border-radius: 11px;
  border: 1px solid transparent;
  min-height: 44px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 800;
}
.primary-button { background: linear-gradient(135deg, #0d8a5d, #07563b); color: white; box-shadow: 0 11px 26px rgba(11, 122, 83, .2); }
.primary-button:hover { filter: brightness(1.04); }
.secondary-button { background: white; border-color: var(--line); color: #34443b; }
.danger-button { background: var(--red-soft); border-color: #efcaca; color: var(--red); }
.text-button { min-height: auto; background: transparent; color: var(--green); padding: 4px 8px; }
.compact { min-height: 36px; padding: 0 13px; font-size: 11px; border-radius: 9px; }
.login-form .primary-button { margin-top: 4px; height: 50px; }
.message { margin-top: 16px; border-radius: 11px; padding: 12px 14px; font-size: 12px; line-height: 1.55; }
.message.error { background: var(--red-soft); color: var(--red); border: 1px solid #f1cccc; }
.message.success { background: var(--green-soft); color: var(--green-2); border: 1px solid #c6ead9; }
.success-panel { margin-top: 22px; border: 1px solid var(--line); border-radius: 18px; padding: 20px; background: #f8fcfa; }
.success-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: white; font-size: 20px; font-weight: 900; }
.success-panel h2 { margin: 13px 0 16px; font-size: 22px; }
.success-panel dl { margin: 0; display: grid; gap: 9px; }
.success-panel dl div { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px dashed #dfe8e2; padding-bottom: 8px; }
.success-panel dt { color: var(--muted); font-size: 11px; }
.success-panel dd { margin: 0; font-size: 11px; font-weight: 750; text-align: right; overflow-wrap: anywhere; }
.success-panel .secondary-button { width: 100%; margin-top: 17px; }
.login-card footer { margin-top: auto; padding-top: 35px; display: flex; justify-content: space-between; color: #849089; font-size: 10px; }
.login-card footer a { color: var(--green); font-weight: 800; }
.login-aside {
  position: relative;
  overflow: hidden;
  color: white;
  background: linear-gradient(150deg, #0c5f43, #052c20);
  padding: 54px 44px;
}
.aside-grid {
  position: absolute; inset: 0; opacity: .22;
  background-image: linear-gradient(rgba(255,255,255,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.13) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}
.login-aside::before, .login-aside::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); }
.login-aside::before { width: 280px; height: 280px; right: -110px; top: -80px; background: rgba(105, 231, 173, .16); }
.login-aside::after { width: 340px; height: 340px; left: -190px; bottom: -190px; border: 1px solid rgba(255,255,255,.14); }
.aside-content { position: relative; margin-top: 120px; }
.aside-tag { display: inline-block; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; padding: 7px 11px; font-size: 9px; letter-spacing: .17em; color: #b9efd9; }
.aside-content h2 { margin: 28px 0 0; font-size: clamp(40px, 5vw, 62px); line-height: .98; letter-spacing: -.06em; }
.aside-content > p { color: rgba(255,255,255,.65); line-height: 1.8; margin: 23px 0 0; font-size: 13px; }
.aside-content ul { list-style: none; padding: 0; margin: 36px 0 0; display: grid; gap: 15px; font-size: 12px; color: rgba(255,255,255,.8); }
.aside-content li::before { content: "✓"; color: #7ce1b2; margin-right: 10px; font-weight: 900; }

.admin-page { background: #f2f5f3; }
.admin-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #edf4ef, #f8faf8); }
.admin-login-card { width: min(440px, 100%); background: white; border: 1px solid var(--line); border-radius: 24px; padding: 34px; box-shadow: var(--shadow); display: grid; gap: 18px; }
.admin-login-card h1 { font-size: 36px; }
.admin-login-card label { display: grid; gap: 7px; }
.back-link { color: var(--muted); font-size: 11px; }
.admin-app { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 27px 20px; background: #0d1c16; color: white; display: flex; flex-direction: column; }
.brand-light .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.brand-light small { color: rgba(255,255,255,.42); }
.sidebar nav { margin-top: 45px; display: grid; gap: 6px; }
.nav-item { border: 0; border-radius: 10px; background: transparent; color: rgba(255,255,255,.58); text-align: left; padding: 12px 13px; font-size: 12px; font-weight: 750; }
.nav-item.active, .nav-item:hover { background: rgba(102, 222, 169, .11); color: #b9efd9; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 18px; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: rgba(255,255,255,.62); }
.sidebar-footer button { border: 0; background: transparent; color: #ff9393; font-size: 11px; }
.admin-main { min-width: 0; padding: 35px clamp(22px, 4vw, 56px) 70px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.admin-header h1 { font-size: 38px; }
.view { display: none; }
.view.active { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 17px; }
.stat span { color: var(--muted); font-size: 10px; }
.stat strong { display: block; margin-top: 10px; font-size: 26px; letter-spacing: -.05em; }
.stat.alert strong { color: var(--red); }
.panel { background: white; border: 1px solid var(--line); border-radius: 19px; padding: 23px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.panel h2 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.panel p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.create-grid { display: grid; grid-template-columns: 1.5fr .55fr .65fr .6fr auto; gap: 10px; align-items: end; }
.create-grid label, .settings-grid label { display: grid; gap: 7px; color: #466055; font-size: 10px; font-weight: 800; }
.created-cards { margin-top: 18px; display: grid; gap: 8px; }
.created-card { display: flex; justify-content: space-between; align-items: center; gap: 15px; border-radius: 10px; padding: 11px 13px; background: #f1f9f5; border: 1px solid #d9eee4; }
.created-card code { font-weight: 900; letter-spacing: .03em; }
.responsive-head { align-items: flex-start; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.toolbar input { width: 230px; height: 38px; }
.toolbar select { width: 125px; height: 38px; }
.batch-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border-radius: 11px; padding: 10px 12px; margin-bottom: 12px; background: #eef8f3; }
.batch-bar span { margin-right: auto; color: var(--green-2); font-size: 11px; font-weight: 800; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { color: var(--muted); text-align: left; font-size: 9px; letter-spacing: .08em; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid #edf2ef; vertical-align: middle; }
td code { font-size: 11px; font-weight: 750; }
.cell-sub { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.status { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 8px; font-size: 9px; font-weight: 850; white-space: nowrap; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.unused { color: #53746a; background: #eef3f0; }
.status.active { color: var(--green-2); background: var(--green-soft); }
.status.auto_blocked, .status.disabled { color: var(--red); background: var(--red-soft); }
.status.expired { color: var(--amber); background: #fff2d9; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.row-actions button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 7px; font-size: 9px; color: #3c5147; }
.row-actions .danger { color: var(--red); border-color: #efcaca; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; color: var(--muted); font-size: 10px; }
.pagination button { border: 1px solid var(--line); border-radius: 8px; background: white; padding: 7px 11px; }
.pagination button:disabled { opacity: .4; }
.settings-grid { display: grid; grid-template-columns: 1fr .7fr .7fr auto; gap: 12px; align-items: end; }
.switch-row { height: 48px; display: flex !important; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; }
.switch-row input { width: 18px; height: 18px; }
.notice { margin-top: 18px; border-radius: 12px; background: #f5f8f6; padding: 14px; color: #596a61; font-size: 10px; line-height: 1.7; }
.notice strong { color: var(--ink); }
.notice p { margin: 4px 0 0; }
.audit-list { display: grid; gap: 8px; }
.audit-item { display: grid; grid-template-columns: 160px 130px 1fr; gap: 12px; border-bottom: 1px solid #edf2ef; padding: 10px 0; font-size: 10px; }
.audit-item time { color: var(--muted); }
.audit-item b { color: var(--green-2); }
.card-dialog { border: 0; border-radius: 20px; width: min(760px, calc(100% - 30px)); padding: 0; box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.card-dialog::backdrop { background: rgba(8,24,17,.46); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; padding: 24px 26px 14px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 7px 0 0; }
.dialog-head button { border: 0; background: transparent; font-size: 25px; color: var(--muted); }
#dialogContent { padding: 20px 26px 28px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.detail-grid div { background: #f5f8f6; border-radius: 10px; padding: 10px; }
.detail-grid span { display: block; color: var(--muted); font-size: 9px; }
.detail-grid strong { display: block; margin-top: 5px; font-size: 11px; overflow-wrap: anywhere; }
.ip-table { margin-top: 18px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; background: #102119; color: white; border-radius: 10px; padding: 11px 15px; font-size: 11px; box-shadow: 0 15px 45px rgba(0,0,0,.25); }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .create-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 850px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-card { min-height: 680px; }
  .admin-app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { grid-template-columns: repeat(4, 1fr); margin-top: 20px; }
  .sidebar-footer { margin-top: 20px; }
  .admin-main { padding: 24px 16px 50px; }
}
@media (max-width: 600px) {
  .login-page { padding: 0; }
  .login-shell { min-height: 100vh; border: 0; border-radius: 0; }
  .login-card { padding: 28px 22px; }
  .hero-copy { margin-top: 45px; }
  .hero-copy h1 { font-size: 36px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .create-grid, .settings-grid { grid-template-columns: 1fr; }
  .responsive-head { display: block; }
  .toolbar { justify-content: flex-start; margin-top: 14px; }
  .toolbar input { width: 100%; }
  .panel { padding: 17px; }
  .sidebar nav { grid-template-columns: repeat(2, 1fr); }
  .audit-item { grid-template-columns: 1fr; gap: 3px; }
  .detail-grid { grid-template-columns: 1fr; }
}
