* {
    box-sizing: border-box;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Segoe UI, Arial, Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
    color: #1f2937;
    background: #f3f4f6;
}

@keyframes spin3d {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.admin-body {
    background: #f4f6fb;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    flex: 0 0 208px;
    width: 208px;
    background: #0f172a;
    color: #e5e7eb;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 20px;
}

.admin-brand {
    font-size: 22px;
    font-weight: 700;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.admin-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    color: #e2e8f0;
}

.admin-nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
}

.admin-sidebar-foot {
    margin-top: auto;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.7;
}

.admin-main {
    flex: 1;
    min-width: 0;
    padding: 20px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.admin-header h1 {
    margin: 0;
    font-size: 28px;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.flash-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.flash-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    padding: 16px 18px;
}

.card + .card {
    margin-top: 18px;
}

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

.stat-card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    padding: 18px;
}

.stat-title {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
}

.actions-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    color: #ffffff;
}

.btn-primary:hover {
    background: #1d4ed8;
    text-decoration: none;
}

.btn-secondary {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1f2937;
}

.btn-warning {
    background: #f59e0b;
    color: #ffffff;
}

.btn-danger {
    background: #dc2626;
    color: #ffffff;
}

.btn-muted {
    background: #f3f4f6;
    color: #374151;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.badge-enabled {
    background: #dcfce7;
    color: #166534;
}

.badge-disabled {
    background: #fee2e2;
    color: #991b1b;
}

.badge-available {
    background: #dbeafe;
    color: #1d4ed8;
}

.table-wrap {
    width: 100%;
    overflow-x: visible;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
    text-align: left;
    font-size: 13px;
}

.data-table th {
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-label {
    font-weight: 600;
    color: #111827;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #ffffff;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.help-text {
    color: #6b7280;
    font-size: 12px;
    line-height: 1.4;
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30%), #eef2ff;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.1);
    padding: 28px;
}

.login-title {
    margin: 0 0 10px;
    font-size: 28px;
}

.login-subtitle {
    margin: 0 0 24px;
    color: #6b7280;
}

.empty-state {
    padding: 36px 18px;
    text-align: center;
    color: #6b7280;
}

.link-block {
    display: block;
    max-width: 100%;
}

.truncate-text {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-form {
    display: inline;
}

.mini-form button {
    margin-top: 6px;
}

.packets-table {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
}

.packets-table .col-id {
    width: 4%;
}

.packets-table .col-title {
    width: 14%;
}

.packets-table .col-mode {
    width: 10%;
}

.packets-table .col-link {
    width: 17%;
}

.packets-table .col-time-meta {
    width: 13%;
}

.packets-table .col-progress {
    width: 13%;
}

.packets-table .col-range {
    width: 13%;
}

.packets-table .col-actions {
    width: 16%;
}

.packet-title-cell {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.packet-title-text {
    font-size: 14px;
}

.packet-subtitle-text {
    font-size: 12px;
}

.mono-text {
    font-family: Consolas, "Courier New", monospace;
}

.packets-table .link-block a {
    max-width: 100%;
}

.meta-stack,
.progress-stack {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.meta-row,
.progress-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.meta-label,
.progress-label {
    flex: 0 0 32px;
    color: #6b7280;
    font-size: 12px;
}

.meta-value,
.progress-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #111827;
    font-size: 13px;
}

.range-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #111827;
    font-size: 13px;
}

.mode-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    max-width: 100%;
    padding: 0 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    align-content: center;
}

.table-actions .mini-form {
    display: inline-flex;
}

.table-actions .mini-form button {
    margin-top: 0;
}

.table-actions .btn {
    min-height: 32px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 12px;
}

.table-status-badge {
    min-height: 32px;
    padding: 0 14px;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.pagination-summary {
    color: #6b7280;
    font-size: 13px;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-btn {
    min-width: 36px;
    padding: 7px 12px;
    font-size: 12px;
}

.pagination-btn.is-disabled {
    cursor: not-allowed;
    color: #9ca3af;
    background: #f9fafb;
    border-color: #e5e7eb;
}

.pagination-btn.is-current {
    cursor: default;
}

.pagination-ellipsis {
    color: #6b7280;
    font-size: 13px;
}

.public-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f1f1f1;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
}

.phone-shell {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #ededed;
}

.status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 28px;
    padding: 0 16px;
    color: #111827;
    font-size: 12px;
    font-weight: 600;
}

.status-icons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.status-icon {
    width: 16px;
    height: 16px;
}

.nav-bar {
    position: absolute;
    top: 28px;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 12px;
    border-bottom: 1px solid #d1d5db;
    background: #ededed;
}

.nav-back {
    width: 28px;
    height: 28px;
    color: #374151;
}

.nav-title {
    margin-left: 14px;
    font-size: 17px;
    font-weight: 500;
}

.chat-screen {
    height: 100%;
    padding: 96px 16px 16px;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0) 22%),
        radial-gradient(circle at 82% 14%, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 18%),
        linear-gradient(180deg, #f5f5f5 0%, #ededed 100%);
}

.chat-timestamp {
    margin-bottom: 16px;
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
}

.chat-row {
    display: flex;
    align-items: flex-start;
}

.avatar-badge {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d8abc 0%, #0d5f9a 100%);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(13, 138, 188, 0.2);
}

.avatar-badge.avatar-image {
    overflow: hidden;
    background: #ffffff;
    color: transparent;
}

.avatar-badge.avatar-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.avatar-badge.large {
    width: 56px;
    height: 56px;
    margin-right: 0;
    font-size: 20px;
    border: 2px solid #d84e43;
}

.packet-bubble {
    position: relative;
    width: 100%;
    max-width: 252px;
    overflow: visible;
    border-radius: 14px;
    border-top-left-radius: 4px;
    background: #fa9d3b;
    box-shadow: 0 8px 18px rgba(250, 157, 59, 0.24);
    cursor: pointer;
}

.packet-bubble::before {
    content: "";
    position: absolute;
    top: 12px;
    left: -7px;
    width: 14px;
    height: 14px;
    border-radius: 2px;
    background: inherit;
    transform: rotate(45deg);
}

.packet-bubble:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.packet-bubble-main {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #f38c22;
}

.packet-copy {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 4px;
}

.packet-icon {
    width: 40px;
    height: 40px;
    margin-right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.packet-greeting {
    color: #ffffff;
    font-size: 15px;
    line-height: 1.4;
}

.packet-status {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    line-height: 1;
}

.packet-bubble-foot {
    padding: 6px 12px;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
    color: rgba(255, 255, 255, 0.82);
    background: rgba(255, 255, 255, 0.12);
    font-size: 10px;
}

.packet-bubble.is-claimed {
    background: #efd2a8;
    box-shadow: none;
}

.packet-bubble.is-claimed::before {
    background: #efd2a8;
}

.packet-bubble.is-claimed:disabled {
    opacity: 1;
}

.packet-bubble.is-claimed .packet-bubble-main {
    border-bottom-color: rgba(205, 160, 101, 0.45);
}

.packet-bubble.is-claimed .packet-greeting,
.packet-bubble.is-claimed .packet-status,
.packet-bubble.is-claimed .packet-bubble-foot {
    color: rgba(255, 255, 255, 0.84);
}

.packet-bubble.is-claimed .packet-bubble-foot {
    background: rgba(255, 255, 255, 0.1);
}

.claim-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: fit-content;
    max-width: calc(100% - 24px);
    margin: 14px auto 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.82);
    color: #4b5563;
    box-shadow: 0 8px 16px rgba(148, 163, 184, 0.16);
    font-size: 14px;
    line-height: 1.3;
}

.claim-notice-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    flex: 0 0 22px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    overflow: hidden;
}

.state-banner {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    color: #374151;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.state-card {
    margin-top: 12px;
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.state-card h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.state-card p {
    margin: 0;
    color: #6b7280;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.hidden {
    display: none !important;
}

.packet-cover-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 300px;
    height: 420px;
    overflow: hidden;
    border-radius: 20px;
    background: #d84e43;
    box-shadow: 0 26px 50px rgba(0, 0, 0, 0.36);
}

.packet-cover-arc {
    position: absolute;
    top: 0;
    left: -25%;
    width: 150%;
    height: 120px;
    border-bottom: 1px solid rgba(248, 113, 113, 0.4);
    border-bottom-left-radius: 100%;
    border-bottom-right-radius: 100%;
    background: #e6554a;
}

.cover-close,
.detail-close,
.nav-back {
    border: 0;
    background: none;
    padding: 0;
}

.cover-close {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    width: 28px;
    height: 28px;
    color: rgba(255, 255, 255, 0.78);
}

.cover-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 48px;
    text-align: center;
}

.cover-title {
    margin: 10px 0 0;
    color: #fbe0aa;
    font-size: 18px;
}

.cover-subtitle {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
}

.cover-message {
    margin: 28px 24px 0;
    color: #fbe0aa;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
}

.open-button-wrap {
    position: absolute;
    bottom: 64px;
    z-index: 2;
}

.open-button {
    width: 96px;
    height: 96px;
    border-radius: 999px;
    border: 0;
    background: #ebcd99;
    color: #d84e43;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    font-size: 40px;
    font-weight: 700;
    cursor: pointer;
}

.animate-spin3d {
    animation: spin3d 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) 1 both;
}

.cover-watermark {
    position: absolute;
    bottom: 16px;
    color: #e2a8a4;
    font-size: 12px;
}

.detail-panel {
    position: absolute;
    inset: 0;
    z-index: 45;
    overflow-y: auto;
    background: #f1f1f1;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.detail-panel.translate-y-0 {
    transform: translateY(0);
}

.detail-close {
    position: absolute;
    top: 28px;
    left: 12px;
    z-index: 3;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.2);
    color: #ffffff;
}

.detail-hero {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 180px;
    border-bottom-left-radius: 30%;
    border-bottom-right-radius: 30%;
    background: #d84e43;
}

.detail-hero-line {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #ebcd99, transparent);
    opacity: 0.5;
}

.detail-hero-avatar {
    position: absolute;
    bottom: -32px;
}

.avatar-frame {
    padding: 4px;
    border-radius: 12px;
    background: #f1f1f1;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.detail-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 48px 20px 0;
    text-align: center;
}

.detail-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 500;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #fcf0d3;
    color: #cf8e30;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
}

.detail-subtitle {
    margin: 6px 0 10px;
    color: #6b7280;
    font-size: 14px;
}

.detail-state {
    margin: 0;
    color: #576b95;
    font-size: 12px;
}

.amount-row {
    display: flex;
    align-items: baseline;
    margin-top: 14px;
    color: #d84e43;
}

.amount-int {
    font-size: 48px;
    font-weight: 700;
}

.amount-dec {
    font-size: 32px;
    font-weight: 700;
}

.amount-unit {
    margin-left: 4px;
    color: #4b5563;
    font-size: 14px;
}

.money-hint {
    margin-top: 12px;
    color: #576b95;
    font-size: 12px;
}

.detail-section {
    padding: 0 16px 40px;
}

.section-title {
    margin: 32px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 12px;
}

.detail-card {
    border-radius: 18px;
    background: #ffffff;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
}

.detail-row + .detail-row {
    border-top: 1px solid #f3f4f6;
}

.detail-label {
    color: #374151;
    font-size: 14px;
}

.detail-value {
    color: #6b7280;
    font-size: 14px;
    text-align: right;
}

.detail-value.mono {
    font-family: Consolas, "Courier New", monospace;
}

.copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    cursor: pointer;
}

.copy-button.success {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.hint-note {
    margin-top: 8px;
    text-align: center;
    color: #9ca3af;
    font-size: 10px;
}

.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

@media (min-width: 640px) {
    .phone-shell {
        width: 400px;
        height: 800px;
        border: 8px solid #1f2937;
        border-radius: 40px;
        box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
    }
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .admin-layout {
        flex-direction: column;
    }

    .admin-sidebar {
        width: auto;
        flex-basis: auto;
    }

    .admin-main {
        padding: 18px;
    }
}

@media (max-width: 640px) {
    .form-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .claim-notice {
        max-width: calc(100% - 24px);
    }
}
