/* ==========================================================================
   CSS map
   1. Base tokens and shared primitives
   2. Public lookup pages
   3. Admin shell and navigation layout
   4. Buttons, forms, and shared controls
   5. Public lookup results
   6. Admin dashboard, imports, and toolbars
   7. Tables, rows, and pagination
   8. Toasts, animations, and responsive rules
   ========================================================================== */

/* 1. Base tokens and shared primitives */
:root {
  color-scheme: light;
  --bg: #f7fbff;
  --surface: #ffffff;
  --surface-soft: #fbf8ff;
  --text: #241842;
  --muted: #766f91;
  --line: #e8defa;
  --line-soft: #f2eefe;
  --primary: #7c5cff;
  --primary-hover: #6848f0;
  --primary-soft: #f0ebff;
  --success: #10bfa9;
  --success-soft: #e9fff9;
  --warning: #d08700;
  --warning-soft: #fff8df;
  --danger: #ff4f8b;
  --danger-hover: #e93c78;
  --danger-soft: #fff0f6;
  --cyan: #18bff2;
  --cyan-soft: #e8faff;
  --pink: #ff7ab6;
  --yellow: #ffcb45;
  --mint: #18d6c5;
  --shadow: 0 16px 38px rgba(87, 70, 150, 0.12);
  --shadow-strong: 0 22px 54px rgba(87, 70, 150, 0.18);
  --radius: 12px;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.top-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 1000;
  min-width: min(360px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 12px 16px;
  color: #047857;
  background: #ecfdf5;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity .18s ease, transform .18s ease;
}

.top-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.top-toast.error {
  border-color: #fecaca;
  color: var(--danger-hover);
  background: var(--danger-soft);
}

.top-toast.info {
  border-color: #bfdbfe;
  color: #2563eb;
  background: #eff6ff;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.brand,
.brand-mark,
nav a,
button,
.field-label,
.with-icon,
.mini-guide div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand,
.brand-mark {
  font-weight: 800;
}

.brand svg,
.brand-mark svg,
nav svg,
button svg,
.field-label svg,
.input-shell svg,
.with-icon svg,
.stat svg,
.empty-state svg,
.mini-guide svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

nav {
  display: flex;
  gap: 6px;
}

nav a {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
}

nav a.active,
nav a:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.layout {
  width: min(1220px, calc(100vw - 32px));
  margin: 24px auto;
}

/* 2. Public lookup pages */
.public-page,
.auth-page {
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 320px),
    var(--bg);
}

.public-shell,
.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.public-shell {
  align-content: center;
  gap: 14px;
}

.panel,
.lookup-panel,
.auth-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  position: relative;
  padding: 20px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(18px) saturate(1.16);
}

.lookup-panel {
  width: min(680px, 100%);
  padding: 28px;
}

.public-compact {
  width: min(620px, 100%);
  padding: 16px;
}

.public-lookup-row {
  grid-template-columns: minmax(0, 1fr) 132px 118px;
}

.public-compact .result:empty {
  display: none;
}

.tutorial-panel {
  width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.tutorial-panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.tutorial-panel ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.tutorial-panel li::marker {
  color: var(--primary);
  font-weight: 900;
}

.auth-box {
  width: min(420px, 100%);
  padding: 26px;
}

.brand-mark {
  width: fit-content;
  min-height: 32px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 13px;
  margin-bottom: 16px;
}

/* 3. Admin shell and navigation layout */
.admin-layout {
  display: grid;
  gap: 16px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  background:
    repeating-linear-gradient(135deg, rgba(255, 203, 69, .12) 0 10px, transparent 10px 30px),
    linear-gradient(135deg, rgba(56, 189, 248, .16), rgba(255, 122, 182, .12) 42%, rgba(24, 214, 197, .12)),
    var(--bg);
  background-attachment: fixed;
  isolation: isolate;
  transition: grid-template-columns .22s ease;
}

.admin-shell.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.admin-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .45;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(124, 92, 255, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 92, 255, .08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000, transparent 76%);
  animation: gridFloat 14s linear infinite;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, .72);
  padding: 18px 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .88), rgba(255, 255, 255, .7)),
    linear-gradient(135deg, rgba(124, 92, 255, .14), rgba(255, 122, 182, .12));
  backdrop-filter: blur(22px) saturate(1.25);
  box-shadow: 12px 0 40px rgba(87, 70, 150, .08);
}

.sidebar-brand {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, var(--primary), var(--pink), var(--mint)) border-box;
  box-shadow: 0 12px 30px rgba(124, 92, 255, .14);
  overflow: hidden;
}

.sidebar-toggle {
  position: relative;
  z-index: 1;
  margin-left: auto;
  width: 30px;
  height: 30px;
  min-height: 30px;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, .82);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}

.sidebar-toggle:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  transform: translateY(-1px);
}

.sidebar-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 0 34%, rgba(255,255,255,.8) 42%, transparent 52% 100%);
  transform: translateX(-110%);
  animation: sheen 5.8s ease-in-out infinite;
  pointer-events: none;
}

.sidebar-brand > svg {
  color: var(--pink);
  filter: drop-shadow(0 4px 8px rgba(255, 122, 182, .36));
}

.sidebar-brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.sidebar-brand svg,
.side-nav-item svg,
.sidebar-links svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.side-nav-item,
.sidebar-links a {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  padding: 0 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

.side-nav-item {
  border-color: transparent;
  background: transparent;
  cursor: pointer;
}

.side-nav-item:hover,
.side-nav-item.active,
.sidebar-links a:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #38bdf8 52%, var(--pink));
  box-shadow: 0 12px 24px rgba(124, 92, 255, .24);
  transform: translateX(3px);
}

.side-nav-item.active svg,
.side-nav-item:hover svg,
.sidebar-links a:hover svg {
  animation: iconWiggle .52s ease;
}

.sidebar-links {
  display: grid;
  gap: 4px;
  border-top: 1px solid rgba(124, 92, 255, .14);
  padding-top: 12px;
}

.admin-shell.sidebar-collapsed .admin-sidebar {
  padding-inline: 10px;
}

.admin-shell.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-inline: 8px;
}

.admin-shell.sidebar-collapsed .sidebar-brand > div,
.admin-shell.sidebar-collapsed .side-nav-item span,
.admin-shell.sidebar-collapsed .sidebar-links span {
  display: none;
}

.admin-shell.sidebar-collapsed .sidebar-toggle {
  position: absolute;
  right: -15px;
  top: 9px;
  margin-left: 0;
  box-shadow: 0 8px 20px rgba(124, 92, 255, .18);
}

.admin-shell.sidebar-collapsed .side-nav-item,
.admin-shell.sidebar-collapsed .sidebar-links a {
  justify-content: center;
  padding-inline: 0;
}

.admin-shell.sidebar-collapsed .side-nav-item:hover,
.admin-shell.sidebar-collapsed .side-nav-item.active,
.admin-shell.sidebar-collapsed .sidebar-links a:hover {
  transform: none;
}

.admin-main {
  min-width: 0;
  padding: 28px;
}

.admin-view {
  display: none;
  gap: 16px;
}

.admin-view.active {
  display: grid;
}

.admin-page-head {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  border: 1px solid rgba(255, 255, 255, .76);
  border-radius: 16px;
  padding: 18px;
  background:
    repeating-linear-gradient(120deg, rgba(255, 203, 69, .12) 0 12px, transparent 12px 26px),
    linear-gradient(135deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .7));
  box-shadow: 0 18px 42px rgba(87, 70, 150, .12);
  overflow: hidden;
}

.admin-page-head::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(124, 92, 255, .45), rgba(24, 214, 197, .3), rgba(255, 122, 182, .42));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: .66;
}

.admin-page-head h1 {
  margin-bottom: 8px;
}

.admin-page-head p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.admin-stats {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: stretch;
}

.overview-grid .admin-stats {
  align-content: stretch;
}

.settings-panel {
  margin-bottom: 16px;
}

.mode-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-option {
  min-height: 38px;
  border: 1px solid rgba(124, 92, 255, .2);
  border-radius: 999px;
  padding: 0 14px;
  color: #5d5377;
  background: rgba(255, 255, 255, .82);
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.mode-option:hover,
.mode-option.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  box-shadow: 0 10px 20px rgba(124, 92, 255, .18);
}

.mode-option:disabled {
  cursor: wait;
  opacity: .7;
}

.chart-panel {
  position: relative;
  display: grid;
  align-content: start;
  min-height: 226px;
  background:
    linear-gradient(135deg, rgba(24, 214, 197, .14), transparent 42%),
    rgba(255, 255, 255, .86);
}

.chart-shell {
  position: relative;
  min-height: 174px;
}

.compact-title {
  margin-bottom: 8px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: 0;
}

.page-heading {
  margin-bottom: 18px;
}

.page-heading p {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  box-shadow: 0 10px 20px rgba(124, 92, 255, .2);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

label {
  display: block;
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 700;
}

.field-label {
  margin-bottom: 9px;
  font-size: 14px;
  font-weight: 700;
}

.input-shell {
  position: relative;
}

.input-shell > svg {
  position: absolute;
  left: 13px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.input-shell input {
  padding-left: 40px;
}

.input-shell.has-clear-search input {
  padding-right: 40px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(124, 92, 255, .2);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, .9);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
  font: 14px/1.4 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

select {
  width: auto;
  min-height: 34px;
  padding-right: 28px;
  color: var(--muted);
  background: rgba(255, 255, 255, .9);
  font-size: 12px;
  font-weight: 800;
}

textarea {
  min-height: 230px;
  resize: vertical;
  padding: 12px;
  font: 13px/1.55 Consolas, "Courier New", monospace;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.14), 0 10px 24px rgba(124, 92, 255, .08);
}

/* 4. Buttons, forms, and shared controls */
button {
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 12px 24px rgba(124, 92, 255, .22);
  transition: background .16s ease, border-color .16s ease, transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

button:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--pink));
  box-shadow: 0 16px 30px rgba(124, 92, 255, .3);
  filter: saturate(1.08);
  transform: translateY(-2px);
}

button:disabled {
  cursor: wait;
  opacity: .72;
  transform: none;
}

.secondary-button {
  color: var(--text);
  border-color: rgba(124, 92, 255, .24);
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 10px 22px rgba(87, 70, 150, .09);
}

.secondary-button:hover {
  color: var(--primary);
  border-color: rgba(124, 92, 255, .4);
  background: #fff;
}

.danger-button {
  color: #fff;
  background: linear-gradient(135deg, var(--danger), #ff9f43);
}

.danger-button:hover {
  background: linear-gradient(135deg, var(--danger-hover), #ff7a45);
}

.wide-danger {
  min-height: 44px;
}

.compact-button {
  min-height: 28px;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
}

.clear-search-button {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 28px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  transform: translateY(-50%);
}

.clear-search-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: none;
  transform: translateY(-50%);
}

.clear-search-button[hidden] {
  display: none;
}

.clear-search-button svg {
  width: 14px;
  height: 14px;
}

/* 5. Public lookup results */
.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.hint,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.with-icon {
  align-items: flex-start;
}

.with-icon svg {
  flex: 0 0 auto;
  margin-top: 1px;
}

.result {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.input-insight {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-top: 10px;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 10px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(240, 235, 255, .72);
  font-size: 12px;
  line-height: 1.45;
}

.input-insight[hidden] {
  display: none;
}

.input-insight svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.input-insight strong {
  color: var(--primary);
  white-space: nowrap;
}

.input-insight span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.recent-lookups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.recent-lookups > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.recent-lookup {
  width: auto;
  min-height: 30px;
  max-width: 100%;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--primary);
  border-color: rgba(124, 92, 255, .22);
  background: var(--primary-soft);
  box-shadow: none;
  font-size: 12px;
}

.recent-lookup:hover {
  color: #fff;
}

.loading-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.loading-state {
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px dashed rgba(124, 92, 255, .28);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, .72);
  font-size: 14px;
  font-weight: 800;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.code-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.password-result {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 12px;
  background: rgba(255, 255, 255, .86);
}

.password-result > div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.password-result strong {
  color: var(--muted);
  font-size: 12px;
}

.password-result .mono-cell {
  max-width: none;
  overflow-wrap: anywhere;
}

.password-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 24, 66, .42);
  backdrop-filter: blur(8px);
}

.password-dialog {
  display: grid;
  gap: 12px;
  width: min(360px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-strong);
}

.password-dialog h2 {
  margin: 0;
  font-size: 18px;
}

.password-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.code {
  display: inline-flex;
  align-items: center;
  min-height: 56px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 0 16px;
  color: #047857;
  background: var(--success-soft);
  font: 800 32px/1.2 Consolas, "Courier New", monospace;
  overflow-wrap: anywhere;
}

.message-code {
  font: 800 18px/1.45 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  padding: 12px 16px;
}

.failed-code {
  border-color: #fecaca;
  color: var(--danger-hover);
  background: var(--danger-soft);
}

.copy-button {
  min-height: 40px;
}

.copy-button.copied {
  color: #047857;
  border-color: #a7f3d0;
  background: var(--success-soft);
}

.error,
.notice,
.warning {
  border-radius: 10px;
  padding: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.result-action-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.retry-button {
  min-height: 34px;
  border-radius: 10px;
}

.error {
  border: 1px solid #fecaca;
  color: var(--danger-hover);
  background: var(--danger-soft);
}

.notice {
  border: 1px solid #a7f3d0;
  color: var(--success);
  background: var(--success-soft);
}

.warning {
  border: 1px solid #fed7aa;
  color: var(--warning);
  background: var(--warning-soft);
}

.meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* 6. Admin dashboard, imports, and toolbars */
.admin-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
}

.admin-hero .page-heading {
  margin-bottom: 0;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
}

.stat {
  position: relative;
  min-width: 130px;
  min-height: 118px;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 16px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .78)),
    repeating-linear-gradient(135deg, rgba(124, 92, 255, .08) 0 8px, transparent 8px 22px);
  box-shadow: 0 16px 34px rgba(87, 70, 150, .13);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.stat:hover {
  border-color: rgba(124, 92, 255, .28);
  box-shadow: 0 22px 46px rgba(87, 70, 150, .18);
  transform: translateY(-4px) rotate(-.4deg);
}

.stat::after {
  content: "";
  position: absolute;
  right: -14px;
  bottom: -18px;
  width: 104px;
  height: 70px;
  border-radius: 18px;
  background: rgba(124, 92, 255, .12);
  box-shadow: inset 0 0 0 10px rgba(255, 255, 255, .24);
  transform: rotate(-14deg);
}

.stat svg {
  position: absolute;
  right: 12px;
  top: 12px;
  color: var(--primary);
  filter: drop-shadow(0 5px 10px rgba(124, 92, 255, .28));
}

.stat span,
.stat strong {
  display: block;
}

.stat span {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--primary);
  text-shadow: 0 8px 18px rgba(124, 92, 255, .16);
}

.stat strong {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.stat.accent-green svg,
.stat.accent-green span {
  color: var(--mint);
}

.stat.accent-green::after {
  background: rgba(24, 214, 197, .14);
}

.stat.accent-cyan svg,
.stat.accent-cyan span {
  color: var(--cyan);
}

.stat.accent-cyan::after {
  background: rgba(24, 191, 242, .15);
}

.stat.accent-pink svg,
.stat.accent-pink span {
  color: var(--pink);
}

.stat.accent-pink::after {
  background: rgba(255, 122, 182, .16);
}

.stat.accent-amber svg,
.stat.accent-amber span {
  color: #f59e0b;
}

.stat.accent-amber::after {
  background: rgba(255, 203, 69, .2);
}

.section-title {
  margin-bottom: 14px;
}

.section-title p {
  margin-bottom: 0;
}

.import-grid {
  display: grid;
  gap: 16px;
}

.key-import-grid {
  display: grid;
  gap: 16px;
}

.import-input,
.import-side {
  min-width: 0;
}

.import-side {
  display: grid;
  align-content: start;
  gap: 14px;
}

.mini-guide {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 14px;
  padding: 13px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 122, 182, .1) 0 8px, transparent 8px 20px),
    var(--surface-soft);
}

.import-panel textarea {
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,255,255,.88)),
    linear-gradient(90deg, rgba(124, 92, 255, .06), rgba(24, 214, 197, .06));
}

.mini-guide div {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mini-guide svg {
  color: var(--primary);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.list-toolbar {
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) auto;
  justify-content: space-between;
  align-items: end;
}

.email-toolbar {
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  grid-template-areas:
    "search actions"
    "filters filters";
  align-items: end;
}

.email-toolbar .search-box {
  grid-area: search;
}

.email-toolbar .toolbar-actions {
  grid-area: actions;
  justify-content: flex-end;
}

.email-toolbar .account-filters {
  grid-area: filters;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.list-toolbar .search-box {
  width: min(360px, 100%);
}

.list-toolbar .export-button {
  min-width: 190px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 1px;
}

.toolbar-filters label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  margin: 0;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 8px 16px rgba(87, 70, 150, .06);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.toolbar-filters label.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  box-shadow: 0 10px 20px rgba(124, 92, 255, .18);
}

.toolbar-filters input {
  width: 13px;
  height: 13px;
  min-height: 0;
  accent-color: var(--primary);
}

.account-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px 12px;
  align-items: end;
  width: 100%;
  min-width: 0;
  padding-bottom: 0;
}

.account-filters.single-filter {
  grid-template-columns: minmax(168px, 240px);
}

.filter-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-group-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.filter-group-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.account-filters label {
  position: relative;
  justify-content: center;
  min-width: 0;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  box-shadow: none;
  white-space: nowrap;
}

.account-filters label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-filters input {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  opacity: 0;
  pointer-events: none;
}

.account-filters label:focus-within {
  outline: 2px solid rgba(124, 92, 255, .35);
  outline-offset: 2px;
}

.toolbar-actions button {
  flex: 0 1 auto;
  min-height: 38px;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 9px 11px;
  border: 1px solid rgba(124, 92, 255, .14);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, .76);
  font-size: 12px;
  font-weight: 700;
}

.filter-summary span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.filter-summary .compact-button {
  min-height: 30px;
  white-space: nowrap;
}

.quick-copy-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 12px;
}

.quick-copy-button {
  width: 100%;
  min-height: 38px;
  justify-content: center;
}

.quick-copy-button svg {
  width: 16px;
  height: 16px;
}

.search-box label {
  margin-bottom: 7px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(124, 92, 255, .16);
  border-radius: 16px;
  background: rgba(255, 255, 255, .84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

/* 7. Tables, rows, and pagination */
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.mail-account-table {
  min-width: 980px;
}

.icloud-account-table,
.phone-account-table {
  min-width: 1120px;
}

.key-table {
  min-width: 900px;
}

.col-check {
  width: 40px;
}

.col-index {
  width: 54px;
}

.col-status {
  width: 84px;
}

.col-updated {
  width: 88px;
}

.col-actions {
  width: 146px;
}

.mail-account-table .col-account {
  width: 30%;
}

.mail-account-table .col-password {
  width: 190px;
}

.icloud-account-table .col-account {
  width: 26%;
}

.icloud-account-table .col-api {
  width: auto;
}

.phone-account-table .col-account {
  width: 18%;
}

.phone-account-table .col-link {
  width: 27%;
}

.phone-account-table .col-count {
  width: 86px;
}

.phone-account-table .col-history {
  width: auto;
}

.key-table .col-key-id {
  width: 27%;
}

.key-table .col-key-expiry {
  width: 120px;
}

.key-table .col-key-secret {
  width: auto;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 10px;
  text-align: left;
  white-space: normal;
  vertical-align: middle;
}

th {
  color: #5b4c85;
  font-weight: 800;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(240, 235, 255, .88));
  position: sticky;
  top: 0;
  z-index: 1;
}

.sort-button {
  width: auto;
  min-height: 28px;
  justify-content: flex-start;
  gap: 5px;
  border-radius: 8px;
  padding: 0 7px;
  color: #5b4c85;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
}

.sort-button:hover,
.sort-button.active {
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: none;
  transform: none;
}

.sort-button svg {
  width: 13px;
  height: 13px;
}

tbody tr:hover {
  background:
    linear-gradient(90deg, rgba(124, 92, 255, .08), rgba(24, 214, 197, .06), rgba(255, 122, 182, .06));
}

.check-cell {
  width: 40px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
  width: 54px;
}

th[data-actions],
td[data-label="操作"] {
  width: 146px;
}

td[data-label="操作"] {
  position: sticky;
  right: 0;
  z-index: 2;
  background: rgba(255, 255, 255, .96);
  box-shadow: -10px 0 18px rgba(87, 70, 150, .08);
}

th[data-actions] {
  position: sticky;
  right: 0;
  z-index: 3;
  box-shadow: -10px 0 18px rgba(87, 70, 150, .08);
}

.row-check {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--primary);
}

.password-cell,
.mono-cell,
td[data-label="client_id"] span {
  font-family: Consolas, "Courier New", monospace;
}

.mono-cell,
td[data-label="client_id"] span {
  display: inline-block;
  max-width: 360px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.link-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
}

.copy-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.truncate-cell {
  max-width: clamp(160px, 26vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-account-table td[data-label="微软邮箱"] .truncate-cell,
.icloud-account-table td[data-label="iCloud邮箱"] .truncate-cell {
  max-width: clamp(190px, 22vw, 360px);
}

.phone-account-table td[data-label="导出短链接"] .truncate-cell,
.icloud-account-table td[data-label="API链接"] .truncate-cell {
  max-width: clamp(260px, 34vw, 680px);
}

.mail-account-table td[data-label="密码"] .truncate-cell,
.key-table td[data-label="密钥"] .truncate-cell {
  max-width: clamp(90px, 10vw, 140px);
}

.detail-copy-cell {
  display: flex;
  flex-wrap: nowrap;
}

.detail-copy-button {
  min-width: 34px;
  padding-inline: 8px;
}

.detail-copy-button span {
  display: none;
}

.icon-button {
  flex: 0 0 auto;
  width: 32px;
  min-height: 32px;
  border-radius: 10px;
  padding: 0;
  color: var(--primary);
  border-color: rgba(124, 92, 255, .25);
  background: var(--primary-soft);
  box-shadow: 0 8px 18px rgba(124, 92, 255, .12);
}

.icon-button:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--pink));
}

.icon-button svg {
  width: 15px;
  height: 15px;
}

.mini-copy {
  width: 26px;
  min-height: 26px;
  border-radius: 8px;
}

.mini-copy svg {
  width: 13px;
  height: 13px;
}

.detail-copy-cell {
  gap: 8px;
}

.detail-copy-button {
  white-space: nowrap;
}

.detail-copy-button svg {
  width: 13px;
  height: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.unused {
  color: #037c72;
  background: linear-gradient(135deg, #d9fff7, #e8faff);
  box-shadow: 0 8px 16px rgba(24, 214, 197, .12);
}

.status-pill.used {
  color: #756788;
  background: #eee8f8;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  box-shadow: 0 8px 18px rgba(124, 92, 255, .18);
  font-weight: 900;
}

.key-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 12px;
}

.key-stats span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, .84);
  box-shadow: 0 8px 16px rgba(87, 70, 150, .06);
  font-size: 12px;
  font-weight: 800;
}

.key-stats strong {
  color: var(--primary);
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}

.status-toggle.used-state {
  background: linear-gradient(135deg, #8b7cf6, #b58cff);
}

.code-history {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.code-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(24, 214, 197, .22);
  border-radius: 10px;
  padding: 6px 8px;
  background: linear-gradient(135deg, #ffffff, #f0fffb);
}

.tippy-box[data-theme~='light-border'] {
  border-color: rgba(124, 92, 255, .24);
  border-radius: 10px;
  color: var(--text);
  box-shadow: 0 16px 34px rgba(87, 70, 150, .18);
  font: 12px/1.4 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  overflow-wrap: anywhere;
}

.code-history-item strong {
  color: #047857;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}

.code-history-item span {
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.single-row-actions {
  grid-template-columns: minmax(86px, 1fr);
}

.row-actions .compact-button {
  white-space: nowrap;
  width: 100%;
  min-height: 28px;
  padding: 0 8px;
}

.row-actions .compact-button svg {
  width: 14px;
  height: 14px;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, .78);
  font-size: 12px;
  font-weight: 800;
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pagination-controls .compact-button {
  min-height: 34px;
}

.page-size-select {
  width: auto;
}

.page-indicator {
  min-width: 68px;
  text-align: center;
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px dashed rgba(124, 92, 255, .34);
  border-radius: 16px;
  padding: 24px;
  color: var(--muted);
  background:
    repeating-linear-gradient(135deg, rgba(255, 203, 69, .12) 0 10px, transparent 10px 22px),
    var(--surface-soft);
  text-align: center;
  font-size: 14px;
}

.empty-state svg {
  width: 28px;
  height: 28px;
}

.empty-state button svg {
  width: 16px;
  height: 16px;
}

.import-error-row {
  margin-top: 6px;
  padding-left: 25px;
}

.import-preview {
  display: grid;
  gap: 12px;
  text-align: left;
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preview-stats span,
.preview-samples span {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  border: 1px solid rgba(124, 92, 255, .18);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, .86);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.preview-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.preview-samples,
.preview-issues {
  display: grid;
  gap: 6px;
}

.preview-issues div {
  display: grid;
  grid-template-columns: minmax(120px, .45fr) minmax(0, 1fr);
  gap: 8px;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--warning);
  background: var(--warning-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.preview-issues strong {
  color: var(--text);
}

/* 8. Toasts, animations, and responsive rules */
.toastify {
  font: 13px/1.4 "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

.swal2-popup {
  border: 1px solid rgba(124, 92, 255, .16);
  border-radius: 18px;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  box-shadow: 0 24px 70px rgba(87, 70, 150, .22);
}

.swal2-title {
  color: var(--text);
  letter-spacing: 0;
}

.swal2-html-container {
  color: var(--muted);
}

.swal2-input {
  border-radius: 10px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.error-inline {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes sheen {
  0%,
  62% {
    transform: translateX(-110%);
  }
  78%,
  100% {
    transform: translateX(110%);
  }
}

@keyframes gridFloat {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 28px 28px, 28px 28px;
  }
}

@keyframes iconWiggle {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  35% {
    transform: rotate(-8deg) scale(1.08);
  }
  70% {
    transform: rotate(8deg) scale(1.08);
  }
}

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

@media (min-width: 960px) {
  .import-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
    align-items: stretch;
  }

  .key-import-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    align-items: stretch;
  }

  .import-side .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .import-panel textarea,
  .key-import-grid textarea {
    min-height: 300px;
  }
}

@media (max-width: 1180px) {
  .list-toolbar {
    grid-template-columns: 1fr;
  }

  .email-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search"
      "actions"
      "filters";
  }

  .email-toolbar .toolbar-actions {
    justify-content: flex-start;
  }

  .email-toolbar .account-filters {
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  }

  .list-toolbar .search-box {
    width: min(420px, 100%);
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .toolbar-filters {
    justify-content: flex-start;
  }

  .toolbar-actions button {
    flex: 1 1 160px;
  }

  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  .mail-account-table,
  .icloud-account-table,
  .phone-account-table,
  .key-table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  tbody tr:hover {
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-bottom: 0;
    padding: 7px 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .check-cell {
    width: auto;
    text-align: left;
  }

  td[data-label="操作"],
  th[data-actions] {
    position: static;
    width: auto;
    box-shadow: none;
  }

  .row-actions {
    grid-template-columns: repeat(2, minmax(112px, 1fr));
    width: 100%;
  }

  .truncate-cell {
    max-width: min(58vw, 520px);
  }
}

@media (max-width: 820px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    grid-template-rows: auto auto auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .admin-shell.sidebar-collapsed .admin-sidebar {
    padding: 14px;
  }

  .admin-shell.sidebar-collapsed .sidebar-brand {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .admin-shell.sidebar-collapsed .sidebar-brand > div,
  .admin-shell.sidebar-collapsed .side-nav-item span,
  .admin-shell.sidebar-collapsed .sidebar-links span {
    display: block;
  }

  .admin-shell.sidebar-collapsed .sidebar-toggle {
    position: relative;
    right: auto;
    top: auto;
    margin-left: auto;
    box-shadow: none;
  }

  .admin-shell.sidebar-collapsed .side-nav-item,
  .admin-shell.sidebar-collapsed .sidebar-links a {
    justify-content: flex-start;
    padding: 0 11px;
  }

  .side-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .sidebar-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-main {
    padding: 16px;
  }

  .admin-page-head {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 16px;
  }

  nav {
    flex-wrap: wrap;
  }

  nav a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .layout {
    width: min(100vw - 20px, 1220px);
    margin: 16px auto;
  }

  .admin-sidebar {
    padding: 12px;
  }

  .side-nav,
  .sidebar-links,
  .admin-stats,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .lookup-panel,
  .auth-box,
  .panel {
    padding: 16px;
  }

  .lookup-row,
  .actions,
  .admin-hero,
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .recent-lookups {
    display: grid;
    grid-template-columns: 1fr;
  }

  .input-insight,
  .result-action-row {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .input-insight strong {
    white-space: normal;
  }

  .preview-stats,
  .preview-issues div {
    grid-template-columns: 1fr;
  }

  .list-toolbar .search-box,
  .list-toolbar .export-button,
  .toolbar-actions,
  .toolbar-filters,
  .toolbar-actions button {
    width: 100%;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .stat-row {
    grid-template-columns: 1fr 1fr;
  }

  button {
    width: 100%;
  }

  .side-nav-item {
    width: 100%;
  }

  h1 {
    font-size: 28px;
  }

  textarea {
    min-height: 180px;
  }
}

@media (max-width: 1080px) {
  .email-toolbar .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .email-toolbar .toolbar-actions button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .email-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "search"
      "actions"
      "filters";
  }

  .email-toolbar .account-filters {
    grid-template-columns: 1fr;
  }

  .email-toolbar .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .quick-copy-bar {
    grid-template-columns: 1fr;
  }
}
