:root {
  color-scheme: light;
  --blue: #1f6feb;
  --blue-dark: #174ea6;
  --cyan: #0891b2;
  --green: #168a5b;
  --amber: #b7791f;
  --red: #d92d20;
  --ink: #1d2733;
  --muted: #687385;
  --soft: #f5f7fb;
  --panel: #ffffff;
  --line: #dbe3ee;
  --shadow: 0 18px 42px rgba(29, 39, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #eef3f9;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(31, 111, 235, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(8, 145, 178, 0.1), transparent 42%),
    #f4f7fb;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid rgba(219, 227, 238, 0.88);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.brand {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(31, 111, 235, 0.22);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.side-nav a {
  min-height: 42px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  color: #536173;
  font-size: 14px;
  font-weight: 700;
}

.side-nav a:hover,
.side-nav a.active {
  background: #eaf2ff;
  color: var(--blue-dark);
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(31, 111, 235, 0.1);
  font-weight: 900;
}

.main-panel {
  width: min(100%, 1280px);
  padding: 24px;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.crumb {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.14;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.top-actions,
.filter-actions,
.drawer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.primary-button,
.ghost-button,
.dark-button,
.danger-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.icon-button {
  width: 38px;
  background: #fff;
  border: 1px solid var(--line);
  color: #344054;
  font-size: 20px;
}

.primary-button,
.dark-button,
.ghost-button,
.danger-button {
  padding: 9px 14px;
}

.primary-button {
  background: var(--blue);
  color: #fff;
}

.dark-button {
  background: #243447;
  color: #fff;
}

.ghost-button {
  background: #fff;
  border: 1px solid var(--line);
  color: #344054;
}

.danger-button {
  background: #fff1f0;
  color: var(--red);
}

.icon-button:hover,
.primary-button:hover,
.ghost-button:hover,
.dark-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(29, 39, 51, 0.1);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card,
.filter-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(29, 39, 51, 0.07);
}

.stat-card {
  min-height: 118px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  margin: 5px 0;
  font-size: 32px;
  line-height: 1;
}

.filter-panel {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 160px 160px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.switch-row span {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.12);
}

.table-panel {
  overflow: hidden;
}

.table-head {
  min-height: 76px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.table-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #536173;
  font-size: 12px;
  font-weight: 900;
}

td {
  font-size: 14px;
}

.link-cell {
  display: grid;
  gap: 4px;
}

.short-link {
  color: var(--blue-dark);
  font-weight: 900;
}

.remark {
  color: var(--muted);
  font-size: 12px;
}

.origin-url {
  max-width: 330px;
  overflow: hidden;
  color: #344054;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 58px;
  padding: 4px 8px;
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.badge.active {
  background: #e8f6ef;
  color: var(--green);
}

.badge.disabled {
  background: #f1f3f6;
  color: #667085;
}

.badge.expired {
  background: #fff4e5;
  color: var(--amber);
}

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

.row-actions button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line);
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.row-actions button:hover {
  border-color: rgba(31, 111, 235, 0.5);
  color: var(--blue-dark);
}

.empty-state {
  display: none;
  min-height: 180px;
  place-items: center;
  gap: 4px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  justify-content: flex-end;
  background: rgba(15, 23, 42, 0.42);
}

.drawer-backdrop.open {
  display: flex;
}

.drawer {
  width: min(100%, 520px);
  height: 100%;
  padding: 22px;
  overflow-y: auto;
  background: #fff;
  box-shadow: var(--shadow);
  animation: drawerIn 180ms ease both;
}

@keyframes drawerIn {
  from {
    transform: translateX(24px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

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

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.switch-row {
  min-height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.16s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--blue);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.result-box {
  padding: 13px;
  display: grid;
  gap: 5px;
  border: 1px dashed #9db7dc;
  border-radius: 8px;
  background: #f4f8ff;
}

.result-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-box strong {
  color: var(--blue-dark);
  word-break: break-all;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 40;
  max-width: min(90vw, 420px);
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(29, 39, 51, 0.94);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

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

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px 14px 0;
    border-right: 0;
    background: transparent;
  }

  .brand {
    margin-bottom: 12px;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
  }

  .side-nav a {
    white-space: nowrap;
  }

  .main-panel {
    padding: 16px;
  }

  .stat-grid,
  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions {
    grid-column: span 2;
    justify-content: flex-end;
  }
}

@media (max-width: 620px) {
  .topbar,
  .table-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .filter-actions,
  .drawer-actions {
    width: 100%;
  }

  .primary-button,
  .dark-button,
  .ghost-button,
  .danger-button {
    flex: 1;
  }

  .stat-grid,
  .filter-panel,
  .field-row {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    grid-column: auto;
  }

  .drawer {
    padding: 18px 14px;
  }
}
