:root {
  --bg-0: #f7f9ff;
  --bg-1: #ffffff;
  --bg-2: #eef4ff;
  --ink-0: #111827;
  --ink-1: #334155;
  --ink-2: #64748b;
  --line: #d7e2f1;
  --primary: #0b57d0;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --primary-ink: #ffffff;
  --warn: #dc2626;
  --success: #0f9d58;
  --shadow-1: 0 1px 2px rgba(2, 6, 23, 0.08), 0 6px 16px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 3px 6px rgba(2, 6, 23, 0.12), 0 14px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  font-family: "Noto Sans SC", "Roboto", sans-serif;
  color: var(--ink-0);
  background:
    radial-gradient(1200px 580px at 108% -14%, rgba(59, 130, 246, 0.22) 0%, transparent 62%),
    radial-gradient(920px 420px at -10% 0%, rgba(16, 185, 129, 0.2) 0%, transparent 62%),
    radial-gradient(860px 380px at 40% 118%, rgba(245, 158, 11, 0.13) 0%, transparent 58%),
    var(--bg-0);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes topDrop {
  from {
    opacity: 0;
    transform: translateY(-18px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes progressShrink {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

@keyframes pillPulse {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), rgba(240, 247, 255, 0.86));
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-status {
  display: flex;
  align-items: center;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  animation: pillPulse 2.2s ease-in-out infinite;
}

.role-user {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.role-agent {
  color: #b45309;
  background: #fff7ed;
  border-color: #fed7aa;
}

.role-admin {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.quick-nav-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1330;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #2563eb 55%, var(--secondary));
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  box-shadow: 0 8px 22px rgba(11, 87, 208, 0.28);
  cursor: pointer;
  transition: transform .12s, box-shadow .2s;
}

.quick-nav-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(11, 87, 208, 0.34);
}

.quick-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  z-index: 1310;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.quick-nav-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: min(340px, 92vw);
  height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 24px rgba(15, 23, 42, 0.18);
  z-index: 1320;
  transition: right .22s ease;
  display: flex;
  flex-direction: column;
}

.quick-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.quick-nav-head h3 {
  margin: 0;
  font-size: 16px;
}

.quick-nav-close {
  border: none;
  background: #eef3fb;
  color: #334155;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.quick-nav-body {
  overflow: auto;
  padding: 10px;
}

.quick-nav-group {
  padding: 8px;
  border-bottom: 1px dashed #e5e7eb;
}

.quick-nav-group:last-child {
  border-bottom: none;
}

.quick-nav-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.quick-nav-link {
  display: block;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 10px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  transition: background .16s, border-color .16s, transform .14s;
}

.quick-nav-link:last-child {
  margin-bottom: 0;
}

.quick-nav-link:hover {
  background: #f8fafc;
  transform: translateX(2px);
}

.quick-nav-link.level-user,
.quick-nav-title.level-user {
  color: #1d4ed8;
}

.quick-nav-link.level-agent,
.quick-nav-title.level-agent {
  color: #b45309;
}

.quick-nav-link.level-admin,
.quick-nav-title.level-admin {
  color: #b91c1c;
}

.quick-nav-link.level-user.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.quick-nav-link.level-agent.active {
  background: #fff7ed;
  border-color: #fed7aa;
}

.quick-nav-link.level-admin.active {
  background: #fef2f2;
  border-color: #fecaca;
}

body.nav-drawer-open {
  overflow: hidden;
}

body.nav-drawer-open .quick-nav-drawer {
  right: 0;
}

body.nav-drawer-open .quick-nav-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.nav-drawer-open .quick-nav-fab {
  transform: scale(0.95);
  opacity: 0.9;
}

.page-wrap {
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.page-wrap-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(460px, 100%);
}

.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow-2);
  animation: riseIn .42s ease both;
}

.auth-card h1 {
  margin: 0 0 6px;
}

.muted {
  color: var(--ink-2);
  margin: 0 0 14px;
  font-size: 14px;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-1);
}

input,
select,
textarea,
button {
  font-family: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--ink-0);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(11, 87, 208, 0.12);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  background: linear-gradient(180deg, #e8f1ff 0%, #dce8fb 100%);
  color: var(--ink-1);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .12s, box-shadow .2s, background .25s, filter .2s;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 24%, rgba(255, 255, 255, 0.42) 42%, transparent 62%);
  transform: translateX(-120%);
  transition: transform .42s ease;
  pointer-events: none;
}

.btn:hover {
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
  filter: saturate(1.05);
}

.btn:hover::after {
  transform: translateX(110%);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #2563eb 62%, var(--secondary));
  color: var(--primary-ink);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.26);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.25);
}

.form-footer {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}

.form-footer a {
  color: var(--primary);
  text-decoration: none;
}

.msg {
  margin-top: 12px;
  font-size: 14px;
  min-height: 20px;
}

.msg.error {
  color: var(--warn);
}

.msg.success {
  color: var(--success);
}

.toast-host {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1600;
  width: min(92vw, 560px);
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #dbe4f2;
  color: #0f172a;
  border-radius: 12px;
  min-height: 44px;
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .2s, transform .2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
  animation: topDrop .24s ease;
}

.toast.leave {
  opacity: 0;
  transform: translateY(-8px);
}

.toast-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.35;
}

.toast-close {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  animation: progressShrink 2.6s linear forwards;
}

.toast-success {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.toast-success .toast-progress {
  background: #22c55e;
}

.toast-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.toast-error .toast-progress {
  background: #ef4444;
}

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

.toast-info .toast-progress {
  background: #3b82f6;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.feature-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-radius: 14px;
  padding: 14px;
  transition: box-shadow .24s, transform .16s, border-color .2s;
  animation: riseIn .44s ease both;
}

.feature-link:hover {
  box-shadow: var(--shadow-1);
  border-color: #9ec5ff;
  transform: translateY(-3px);
}

.feature-link h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.feature-link p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-1);
  animation: riseIn .42s ease both;
  transition: transform .18s ease, box-shadow .22s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef3fb;
  color: #1f3b66;
  border: 1px solid #d9e5fb;
  font-size: 13px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.inline-form input,
.inline-form select {
  min-width: 150px;
  flex: 1;
}

.input-with-btn {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.input-with-btn input {
  flex: 1;
  min-width: 0;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f7;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f8fbff;
  color: #36527c;
  position: sticky;
  top: 0;
  z-index: 1;
}

pre.result-box {
  margin: 8px 0 0;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 12px;
  min-height: 40px;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
}

.role-only {
  display: none;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 1700;
  padding: 16px;
}

.modal-card {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  padding: 18px;
}

.modal-card h3 {
  margin: 0 0 12px;
}

.confirm-card {
  width: min(460px, 100%);
}

.confirm-text {
  margin: 0;
  color: var(--ink-1);
  line-height: 1.5;
}

.modal-form {
  display: grid;
  gap: 10px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.modal-open {
  overflow: hidden;
}

body.modal-open .quick-nav-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

@media (max-width: 920px) {
  .topbar-inner {
    padding: 12px;
    gap: 10px;
  }

  .brand {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 62vw;
  }

  .role-pill {
    padding: 5px 8px;
    font-size: 11px;
  }

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

  .quick-nav-fab {
    right: 14px;
    bottom: 14px;
  }

  .page-wrap {
    padding: 12px;
  }

  .card,
  .auth-card {
    padding: 14px;
    border-radius: 14px;
  }

  .card h2 {
    font-size: 18px;
  }

  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .inline-form input,
  .inline-form select,
  .inline-form button {
    width: 100%;
    min-width: 0;
  }

  .input-with-btn {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .input-with-btn .btn {
    width: 100%;
  }

  table {
    min-width: 100%;
  }

  th,
  td {
    white-space: normal;
    word-break: break-word;
  }

  .toast-host {
    width: calc(100vw - 16px);
    top: 8px;
  }
}

@media (max-width: 560px) {
  .topbar-inner {
    padding: 10px;
  }

  .brand {
    font-size: 15px;
    max-width: 58vw;
  }

  .quick-nav-fab {
    right: 10px;
    bottom: 10px;
    padding: 10px 13px;
    font-size: 12px;
  }

  .quick-nav-drawer {
    width: 100vw;
    right: -100vw;
    border-left: none;
  }

  .quick-nav-head {
    padding: 12px 12px 10px;
  }

  .quick-nav-body {
    padding: 8px;
  }

  .page-wrap {
    padding: 10px;
  }

  .modal-mask {
    padding: 10px;
  }

  .modal-card,
  .confirm-card {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .modal-actions .btn {
    width: 100%;
    padding-left: 10px;
    padding-right: 10px;
  }

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