* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #222;
}

.container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.container.wide {
  align-items: flex-start;
}

.card {
  width: 100%;
  max-width: 560px;
  background: #fff;
  padding: 32px;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

.wide .card {
  max-width: 1100px;
}

h1 {
  margin-top: 0;
  font-size: 32px;
}

p {
  line-height: 1.6;
  color: #555;
}

.form-group {
  margin: 24px 0;
}

.form-group.compact {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-size: 16px;
  background: #fff;
  color: #222;
}

button {
  border: none;
  background: #222;
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.result {
  margin-top: 28px;
  padding: 20px;
  background: #f7f7f7;
  border-radius: 16px;
}

.hidden {
  display: none;
}

.button-row,
.short-url-row,
.admin-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.short-url-row a {
  word-break: break-all;
  color: #222;
  font-weight: 600;
}

.secondary-btn,
.secondary-action-btn {
  display: inline-block;
  text-decoration: none;
  background: #f1f1f1;
  color: #222;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 16px;
  border: 1px solid #ddd;
}

.small-btn {
  margin-top: 12px;
  background: #444;
  padding: 10px 14px;
  font-size: 14px;
}

.danger-btn {
  background: #c0392b;
}

.danger-btn:hover {
  opacity: 0.9;
}

.qr {
  width: 220px;
  height: 220px;
  margin-top: 12px;
  border-radius: 12px;
}

.hint {
  color: #666;
  font-size: 14px;
}

.small-field {
  margin-top: -8px;
}

.small-field input {
  padding: 12px 14px;
  font-size: 15px;
}

.source-pill,
.source-tag {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f1f1;
  color: #444;
  font-size: 13px;
  font-weight: 600;
}

.source-pill {
  margin: 0 0 12px 0;
}

.source-tag {
  max-width: 96px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

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

.page-header p {
  margin-top: 0;
}

.admin-list {
  margin-top: 28px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.stat-card {
  padding: 20px;
  border-radius: 16px;
  background: #f7f7f7;
  border: 1px solid #eee;
}

.stat-card span {
  display: block;
  color: #666;
  font-size: 14px;
  margin-bottom: 8px;
}

.stat-card strong {
  display: block;
  font-size: 32px;
  color: #222;
}

.admin-filters {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-top: 24px;
}

.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  margin-bottom: 12px;
  color: #666;
  font-size: 14px;
}

.empty-state {
  margin-top: 28px;
  padding: 24px;
  border-radius: 16px;
  background: #f7f7f7;
  border: 1px solid #eee;
}

.empty-state p {
  margin: 0;
}

.empty-state .hint {
  margin-top: 8px;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid #eee;
  border-radius: 16px;
  background: #fff;
  position: relative;
}

.admin-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

.admin-table thead {
  background: #f7f7f7;
}

.admin-table th,
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.admin-table th {
  color: #555;
  font-weight: 700;
  white-space: nowrap;
}

.admin-table tbody tr:hover {
  background: #fafafa;
}

.admin-table input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: #222;
}

.admin-table th:first-child,
.admin-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: center;
  min-width: 58px;
  background: #fff;
  box-shadow: 8px 0 16px rgba(0, 0, 0, 0.04);
}

.admin-table th:first-child {
  background: #f7f7f7;
  z-index: 5;
}

.admin-table td:first-child {
  z-index: 4;
}

.admin-table th:first-child input[type="checkbox"],
.admin-table td:first-child input[type="checkbox"] {
  vertical-align: middle;
}

.table-url-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.table-url-cell a {
  color: #222;
  font-weight: 700;
  word-break: break-all;
}

.table-original-url {
  width: 260px;
  max-height: 44px;
  overflow: hidden;
  color: #555;
  line-height: 1.5;
  word-break: break-all;
  margin: 0;
}

.table-click-count {
  font-size: 22px;
  color: #222;
}

.status-active,
.status-inactive {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.status-active {
  background: #e8f7ee;
  color: #1e7e44;
}

.status-inactive {
  background: #fbeaea;
  color: #b02a37;
}

.table-qr {
  width: 64px;
  height: 64px;
  border-radius: 8px;
}

.table-date {
  display: inline-block;
  min-width: 150px;
  color: #555;
  font-size: 13px;
}

.small-inline-btn {
  width: fit-content;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 8px;
}

.sticky-action-header,
.sticky-action-cell {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -8px 0 16px rgba(0, 0, 0, 0.06);
}

.sticky-action-header {
  background: #f7f7f7;
  z-index: 6;
}

.sticky-action-cell {
  min-width: 88px;
  text-align: center;
}

.delete-link-btn {
  white-space: nowrap;
  padding: 10px 12px;
  border-radius: 10px;
}

.auth-card {
  max-width: 460px;
}

.auth-switch {
  margin-top: 20px;
  font-size: 14px;
}

.auth-switch a {
  color: #222;
  font-weight: 700;
}

.auth-status {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border-radius: 16px;
  background: #f7f7f7;
  border: 1px solid #eee;
  margin: 20px 0 24px 0;
  flex-wrap: wrap;
}

.auth-status p {
  margin: 6px 0 0 0;
  font-size: 14px;
}

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

.super-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid #eee;
}

.super-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-header h2 {
  margin: 0;
  font-size: 24px;
}

.section-header p {
  margin: 8px 0 0 0;
}

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

.super-link-filters {
  grid-template-columns: 1.5fr 0.7fr 0.8fr;
}

.super-user-table {
  min-width: 1080px;
}

.super-link-table {
  min-width: 1280px;
}

.super-actions-cell {
  min-width: 180px;
}

.super-actions-cell button {
  margin: 4px 0;
}

.danger-zone {
  padding: 24px;
  border: 1px solid #f2c4bd;
  background: #fff7f6;
  border-radius: 16px;
}

.danger-zone .section-header {
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .card {
    padding: 20px;
  }

  .admin-stats,
  .admin-filters {
    grid-template-columns: 1fr;
  }

  .admin-toolbar {
    align-items: stretch;
  }

  .admin-toolbar button {
    width: 100%;
  }

  .admin-table {
    min-width: 1000px;
  }

  .admin-table th,
  .admin-table td {
    padding: 12px;
    font-size: 13px;
  }

  .admin-table input[type="checkbox"] {
    width: 24px;
    height: 24px;
  }

  .admin-table th:first-child,
  .admin-table td:first-child {
    min-width: 64px;
    left: 0;
  }

  .table-original-url {
    width: 220px;
  }

  .table-qr {
    width: 56px;
    height: 56px;
  }

  .sticky-action-cell {
    min-width: 78px;
  }

  .delete-link-btn {
    padding: 9px 10px;
    font-size: 13px;
  }

  .auth-status {
    flex-direction: column;
  }

  .auth-actions {
    width: 100%;
  }

  .auth-actions a,
  .auth-actions button {
    width: 100%;
    text-align: center;
  }

  .super-stats {
    grid-template-columns: 1fr;
  }

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

  .section-header {
    flex-direction: column;
  }

  .section-header button,
  .danger-zone button {
    width: 100%;
  }
}