:root {
  --ink: #16211b;
  --muted: #6b786f;
  --line: #dde5df;
  --canvas: #f4f6f3;
  --panel: #fff;
  --green: #176b48;
  --green-dark: #105238;
  --green-soft: #e8f4ed;
  --amber: #aa6a17;
  --amber-soft: #fff3dc;
  --red: #a73f3f;
  --red-soft: #faeeee;
  --shadow: 0 24px 70px rgba(25, 45, 34, .11);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 31px; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.025em; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.button:hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--green); background: var(--green-soft); }
.button.ghost { background: #fff; border-color: var(--line); }
.button.danger { color: var(--red); background: var(--red-soft); }
.button.wide { width: 100%; min-height: 48px; }
.plus { font-size: 18px; font-weight: 400; line-height: 1; }

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(23,107,72,.14), transparent 28rem),
    radial-gradient(circle at 90% 95%, rgba(23,107,72,.08), transparent 25rem),
    #eef2ee;
}

.login-card {
  width: min(430px, 100%);
  padding: 42px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(22,33,27,.08);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 47px;
  height: 47px;
  margin-bottom: 28px;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 14px;
  font-family: Georgia, serif;
  font-size: 25px;
  font-style: italic;
}

.brand-mark.small { width: 36px; height: 36px; margin: 0; border-radius: 11px; font-size: 19px; }
.login-card h1 { font-family: Georgia, "Songti SC", serif; font-size: 36px; font-weight: 500; }
.login-copy { margin: 9px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.login-form label { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 700; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 62px !important; }

input, textarea, select {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d5ded8;
  border-radius: 9px;
  outline: none;
  transition: border .15s ease, box-shadow .15s ease;
}

input, select { height: 43px; padding: 0 12px; }
textarea { padding: 11px 12px; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #70a88d; box-shadow: 0 0 0 3px rgba(23,107,72,.1); }

.text-button {
  position: absolute;
  top: 50%;
  right: 7px;
  padding: 5px 7px;
  color: var(--green);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  transform: translateY(-50%);
}

.form-error { min-height: 19px; margin: 8px 0; color: var(--red); font-size: 12px; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; color: var(--muted); font-size: 11px; }
.secure-dot { width: 7px; height: 7px; flex: 0 0 auto; background: #36a36d; border-radius: 50%; box-shadow: 0 0 0 4px rgba(54,163,109,.11); }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 26px 17px 18px; color: #e7efe9; background: #14271d; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 29px; }
.brand strong, .brand span { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.brand span { margin-top: 2px; color: rgba(255,255,255,.47); font-size: 10px; }
.nav-item { display: flex; width: 100%; min-height: 43px; align-items: center; gap: 11px; padding: 0 12px; color: rgba(255,255,255,.64); background: transparent; border: 0; border-radius: 9px; font-size: 13px; font-weight: 650; text-align: left; cursor: pointer; }
.nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-icon { display: grid; width: 21px; place-items: center; font-size: 16px; }
.sidebar-foot { margin-top: auto; }
.vault-state { display: flex; align-items: center; gap: 11px; margin: 0 9px 16px; padding-bottom: 17px; border-bottom: 1px solid rgba(255,255,255,.1); }
.vault-state strong, .vault-state span { display: block; }
.vault-state strong { font-size: 11px; }
.vault-state div span { margin-top: 2px; color: rgba(255,255,255,.4); font-size: 9px; }

.content { min-width: 0; padding: 39px clamp(24px, 4vw, 55px) 55px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.subcopy { margin: 0; color: var(--muted); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 20px; }
.stat-card { display: flex; min-height: 112px; align-items: center; justify-content: space-between; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.stat-card p { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.stat-card strong { font-size: 27px; letter-spacing: -.035em; }
.stat-card.featured { color: #fff; background: var(--green); border-color: var(--green); }
.stat-card.featured p { color: rgba(255,255,255,.66); }
.stat-symbol { color: rgba(255,255,255,.18); font-family: Georgia, serif; font-size: 38px; }
.status-orb { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 7px currentColor; opacity: .18; }
.status-orb.green { color: #35a56e; background: #35a56e; }
.status-orb.amber { color: #d0943e; background: #d0943e; }
.status-orb.gray { color: #7e8982; background: #7e8982; }

.panel { overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.search-wrap { position: relative; width: min(380px, 100%); }
.search-wrap span { position: absolute; top: 50%; left: 12px; color: var(--muted); transform: translateY(-50%); }
.search-wrap input { height: 39px; padding-left: 36px; background: #f8faf8; }
.toolbar select { width: 126px; height: 39px; background: #f8faf8; font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 15px; color: var(--muted); background: #f8faf8; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 700; text-align: left; white-space: nowrap; }
td { padding: 15px; border-bottom: 1px solid var(--line); font-size: 12px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfb; }
.account-cell { min-width: 190px; }
.account-cell strong, .account-cell span { display: block; }
.account-cell strong { margin-bottom: 4px; font-size: 13px; }
.account-cell span { max-width: 250px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.region-chip { display: inline-flex; padding: 5px 8px; color: #526159; background: #f0f3f1; border-radius: 7px; font-size: 10px; white-space: nowrap; }
.auth-flags { display: flex; gap: 5px; min-width: 104px; }
.auth-flag { padding: 4px 6px; color: #77827c; background: #f0f3f1; border-radius: 5px; font-size: 9px; }
.auth-flag.ready { color: var(--green); background: var(--green-soft); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 99px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.status-pill::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.status-normal { color: var(--green); background: var(--green-soft); }
.status-wait { color: var(--amber); background: var(--amber-soft); }
.status-off { color: #707a74; background: #edf0ee; }
.date-cell { color: var(--muted); white-space: nowrap; }
.row-action { padding: 6px 9px; color: var(--green); background: transparent; border: 1px solid var(--line); border-radius: 7px; font-size: 10px; font-weight: 700; cursor: pointer; }
.row-action:hover { background: var(--green-soft); border-color: #c8ded1; }
.empty-state, .loading-state { padding: 65px 20px; text-align: center; }
.empty-state h2 { margin: 13px 0 7px; font-size: 16px; }
.empty-state p { margin-bottom: 20px; color: var(--muted); font-size: 12px; }
.empty-icon { display: grid; width: 42px; height: 42px; margin: auto; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 12px; font-size: 22px; }
.loading-state { color: var(--muted); font-size: 12px; }
.panel-foot { display: flex; justify-content: space-between; gap: 16px; padding: 12px 17px; color: var(--muted); background: #fafbfa; border-top: 1px solid var(--line); font-size: 10px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; overflow-y: auto; padding: 28px; place-items: center; background: rgba(10,21,15,.48); backdrop-filter: blur(4px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 56px); overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: 0 28px 90px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 23px 25px; border-bottom: 1px solid var(--line); }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; color: var(--muted); background: #f2f4f2; border: 0; border-radius: 9px; font-size: 21px; cursor: pointer; }
#accountForm { padding: 23px 25px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: block; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 700; }
.field b { color: var(--red); }
.secret-wrap { position: relative; }
.secret-wrap textarea { padding-right: 62px; font-family: Consolas, monospace; font-size: 11px; }
.copy-button { position: absolute; top: 8px; right: 8px; padding: 5px 8px; color: var(--green); background: var(--green-soft); border: 0; border-radius: 6px; font-size: 9px; font-weight: 750; cursor: pointer; }
.modal-foot { display: flex; align-items: center; gap: 9px; margin: 6px -25px 0; padding: 16px 25px; background: #fafbfa; border-top: 1px solid var(--line); border-radius: 0 0 18px 18px; }
.foot-spacer { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 50; padding: 11px 16px; color: #fff; background: #13231a; border-radius: 9px; box-shadow: 0 12px 35px rgba(0,0,0,.22); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  th:nth-child(3), td:nth-child(3), th:nth-child(6), td:nth-child(6) { display: none; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 16px; flex-direction: row; align-items: center; }
  .brand { padding: 0; }
  .brand span, .sidebar nav, .vault-state { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .nav-item.muted { min-height: 36px; }
  .content { padding: 25px 14px 36px; }
  .topbar { align-items: flex-end; margin-bottom: 22px; }
  .topbar h1 { font-size: 27px; }
  .subcopy { display: none; }
  .stats { gap: 8px; }
  .stat-card { min-height: 92px; padding: 15px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-wrap { width: 100%; }
  .toolbar select { width: 100%; }
  th:nth-child(2), td:nth-child(2), th:nth-child(5), td:nth-child(5) { display: none; }
  .panel-foot span:last-child { display: none; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .form-grid > div:empty { display: none; }
}

@media (max-width: 430px) {
  .login-card { padding: 30px 24px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 86px; }
  .stat-card strong { font-size: 23px; }
  .topbar .button { padding: 0 12px; }
}
