/* ── Reset & Base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-light: #eff6ff;
    --blue-bg: #dbeafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.04);
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", sans-serif;
    background: #f0f2f5;
    color: var(--gray-900);
    line-height: 1.65;
    font-size: 15px;
}

a { color: var(--blue); text-decoration: none; transition: color .15s; }
a:hover { color: var(--blue-dark); }

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar {
    background: linear-gradient(135deg, #1e3a5f, #1a56db);
    color: #fff; padding: 0 28px;
    box-shadow: 0 2px 12px rgba(0,0,0,.12);
    position: sticky; top: 0; z-index: 100;
}
.nav-inner {
    max-width: 1500px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 58px;
}
.nav-brand {
    font-size: 1.35em; font-weight: 700; color: #fff !important;
    letter-spacing: .5px; display: flex; align-items: center; gap: 8px;
}
.nav-brand::before { content: "🔍"; font-size: 1.15em; }
.nav-links { display: flex; align-items: center; gap: 22px; }
.nav-links a { color: rgba(255,255,255,.85); font-size: .97em; padding: 4px 0; }
.nav-links a:hover { color: #fff; }
.nav-user { color: rgba(255,255,255,.6); font-size: .9em; margin-left: 4px; }
.btn-logout {
    background: rgba(255,255,255,.12); padding: 6px 18px; border-radius: 6px;
    font-size: .88em !important; transition: background .2s;
}
.btn-logout:hover { background: rgba(255,255,255,.22); }

/* ── Container ───────────────────────────────────────────────────────── */
.container { max-width: 1500px; margin: 24px auto; padding: 0 28px; }

/* ── Flash Messages ──────────────────────────────────────────────────── */
.flash-messages { margin-bottom: 18px; }
.flash-msg {
    background: var(--blue-light); border: 1px solid var(--blue-bg);
    padding: 12px 18px; border-radius: 8px; margin-bottom: 8px;
    font-size: .95em; color: var(--blue-dark);
}

/* ── Auth Box ────────────────────────────────────────────────────────── */
.auth-box {
    max-width: 440px; margin: 80px auto;
    background: var(--white); padding: 44px 40px;
    border-radius: 14px; box-shadow: var(--shadow-md);
}
.auth-box h2 {
    text-align: center; margin-bottom: 6px; color: var(--blue); font-size: 1.6em;
}
.auth-box h2::after {
    content: ""; display: block; width: 48px; height: 3px;
    background: var(--blue); margin: 12px auto 24px; border-radius: 2px;
}
.auth-box label {
    display: block; margin-bottom: 5px; font-weight: 600;
    font-size: .9em; color: var(--gray-700);
}
.auth-box input {
    width: 100%; padding: 12px 16px; margin-bottom: 18px;
    border: 1.5px solid var(--gray-300); border-radius: 8px;
    font-size: .97em; transition: border-color .2s, box-shadow .2s;
    background: var(--gray-50);
}
.auth-box input:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12); background: #fff;
}
.auth-link { text-align: center; margin-top: 18px; font-size: .93em; color: var(--gray-500); }

/* ── Remember Me Checkbox ────────────────────────────────────────────── */
.remember-label {
    display: flex; align-items: center; gap: 8px; margin-bottom: 18px;
    font-size: .93em; color: var(--gray-500); cursor: pointer; user-select: none;
    font-weight: 400;
}
.remember-label input[type="checkbox"] {
    width: 16px !important; height: 16px; margin: 0; padding: 0;
    accent-color: var(--blue); cursor: pointer; background: transparent;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
    display: block; width: 100%; padding: 12px;
    background: var(--blue); color: #fff; border: none; border-radius: 8px;
    font-size: .97em; font-weight: 600; cursor: pointer;
    transition: all .2s;
}
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-danger {
    background: #ef4444; color: #fff; border: none;
    border-radius: 6px; padding: 5px 14px; cursor: pointer; font-size: .85em;
    transition: background .2s;
}
.btn-danger:hover { background: #dc2626; }
.btn-sm { font-size: .83em; padding: 4px 12px; }
.btn-outline {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 16px; border: 1.5px solid var(--gray-300); border-radius: 6px;
    background: #fff; color: var(--gray-700); font-size: .88em; cursor: pointer;
    transition: all .15s;
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-clear {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 8px 16px; background: #fff; border: 1px solid var(--gray-300);
    border-radius: 6px; font-size: .88em; color: var(--gray-500); transition: all .15s;
}
.btn-clear:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }

/* ── Dashboard Header ────────────────────────────────────────────────── */
.dashboard-header {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.dashboard-header h2 {
    margin-bottom: 0; text-align: left; font-size: 1.4em;
}
.update-info {
    font-size: .9em; color: var(--gray-500);
    background: var(--white); padding: 5px 16px;
    border-radius: 16px; border: 1px solid var(--gray-200);
}

/* ── NEW Badge ──────────────────────────────────────────────────────── */
.badge-new {
    display: inline-block; padding: 2px 7px; margin-right: 5px;
    background: #dc2626; color: #fff; font-size: .7em; font-weight: 700;
    border-radius: 4px; vertical-align: middle; letter-spacing: .5px;
}

/* ── Filter Bar ──────────────────────────────────────────────────────── */
.filter-bar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    margin-bottom: 18px; background: var(--white); padding: 16px 22px;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter-group { display: flex; align-items: center; gap: 7px; }
.filter-group label { font-weight: 600; font-size: .88em; color: var(--gray-500); white-space: nowrap; }
.filter-group select {
    padding: 8px 36px 8px 14px; border: 1.5px solid var(--gray-300);
    border-radius: 7px; font-size: .9em; background: #fff;
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    transition: border-color .2s;
}
.filter-group select:focus { outline: none; border-color: var(--blue); }

/* ── Table ───────────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto; background: var(--white);
    border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}
.data-table {
    width: 100%; border-collapse: collapse; font-size: .91em; min-width: 1300px;
}
.data-table thead { background: var(--gray-100); }
.data-table th {
    padding: 13px 14px; text-align: center; font-weight: 600;
    border-bottom: 2px solid var(--gray-200); white-space: nowrap;
    position: sticky; top: 0; background: var(--gray-100);
    font-size: .87em; color: var(--gray-700);
}
.data-table th.sortable {
    cursor: pointer; user-select: none; transition: background .15s;
}
.data-table th.sortable:hover { background: var(--blue-bg); color: var(--blue); }
.data-table td {
    padding: 13px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle;
    text-align: center;
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--blue-light); }

/* ── Image + QR Cell ─────────────────────────────────────────────────── */
.img-qr-cell { display: flex; gap: 10px; align-items: center; justify-content: center; }
.img-qr-cell a { display: inline-block; line-height: 0; }
.img-qr-cell img {
    width: 64px; height: 64px; object-fit: cover;
    border-radius: 8px; border: 1px solid var(--gray-200);
    cursor: zoom-in; transition: transform .2s, box-shadow .2s;
}
.img-qr-cell img:hover { transform: scale(1.15); box-shadow: var(--shadow-md); }
.img-qr-cell img.qr-img { width: 56px; height: 56px; }

/* ── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox-overlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; z-index: 9999;
    background: rgba(0,0,0,.88); justify-content: center; align-items: center;
    cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
    max-width: 92vw; max-height: 92vh; object-fit: contain;
    border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
    cursor: default;
}
.lightbox-close {
    position: fixed; top: 20px; right: 32px;
    font-size: 40px; color: #fff; cursor: pointer; z-index: 10000;
    transition: opacity .2s; line-height: 1;
}
.lightbox-close:hover { opacity: .7; }
.lightbox-hint {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,.5); font-size: .88em; pointer-events: none;
}

/* ── Name + UID Cell ─────────────────────────────────────────────────── */
.name-cell { max-width: 320px; text-align: left !important; }
.name-title {
    font-weight: 500; color: var(--gray-900); line-height: 1.45;
    cursor: pointer; padding: 2px 5px; border-radius: 4px; margin: -2px -5px;
    transition: background .15s; word-break: break-word;
}
.name-title:hover { background: var(--blue-bg); }
.name-uid {
    font-size: .8em; color: var(--gray-500); margin-top: 4px;
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    cursor: pointer; padding: 1px 5px; border-radius: 4px; margin-left: -5px;
    transition: background .15s; display: inline-block;
}
.name-uid:hover { background: var(--blue-bg); color: var(--blue); }

/* ── Copy flash feedback ─────────────────────────────────────────────── */
.name-title.copied, .name-uid.copied {
    background: #d1fae5 !important;
    transition: background 0s;
}

/* ── Copy toast ──────────────────────────────────────────────────────── */
.copy-toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
    background: var(--gray-900); color: #fff; padding: 12px 28px;
    border-radius: 24px; font-size: .92em; z-index: 999;
    animation: toastIn .3s ease, toastOut .3s ease 1.2s forwards;
    pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* ── Country / Category tags ─────────────────────────────────────────── */
.tag {
    display: inline-block; padding: 4px 12px; border-radius: 14px;
    font-size: .84em; font-weight: 600; white-space: nowrap;
}
.tag-country { background: var(--blue-light); color: var(--blue-dark); }
.tag-category { background: #f0fdf4; color: #166534; }

/* ── Money / Rate ────────────────────────────────────────────────────── */
.money { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .92em; }
.rate { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; font-size: .92em; }

/* ── Link Cell ───────────────────────────────────────────────────────── */
.link-cell { white-space: nowrap; }
.link-cell a {
    display: inline-block; padding: 4px 12px; margin: 1px;
    background: var(--gray-100); border-radius: 5px;
    font-size: .84em; color: var(--gray-700); transition: all .15s;
}
.link-cell a:hover { background: var(--blue); color: #fff; }

/* ── Page Headers ────────────────────────────────────────────────────── */
h2 {
    font-size: 1.35em; color: var(--gray-900); margin-bottom: 18px; text-align: center;
}
h3 {
    font-size: 1.1em; color: var(--gray-900); margin-bottom: 14px;
}
h2 .count { vertical-align: baseline; }

/* ── Badge ───────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 3px 12px; border-radius: 12px;
    font-size: .84em; font-weight: 600;
}
.badge-available { background: #d1fae5; color: #065f46; }
.badge-used { background: #fee2e2; color: #991b1b; }

/* ── Card / Box ──────────────────────────────────────────────────────── */
.card {
    background: var(--white); padding: 28px; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}

/* ── Inline Form / Upload ────────────────────────────────────────────── */
.inline-form {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 22px; background: var(--white); padding: 18px 22px;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.inline-form label { font-weight: 600; font-size: .9em; color: var(--gray-700); }
.inline-form input[type="text"] {
    padding: 9px 14px; border: 1.5px solid var(--gray-300); border-radius: 7px;
    font-size: .93em; transition: border-color .2s;
}
.inline-form input[type="text"]:focus { outline: none; border-color: var(--blue); }
.inline-form input[type="number"] {
    padding: 9px 14px; border: 1.5px solid var(--gray-300); border-radius: 7px;
    font-size: .93em; width: 75px; transition: border-color .2s;
}
.inline-form input[type="number"]:focus { outline: none; border-color: var(--blue); }
.inline-form .btn-primary, .inline-form .btn-outline { width: auto; padding: 9px 18px; }

.upload-box { max-width: 640px; }
.upload-box input[type="file"] { margin: 12px 0; font-size: .93em; }
.upload-box .btn-primary { width: auto; margin-top: 12px; }
.hint { color: var(--gray-500); font-size: .86em; margin: 10px 0 0; line-height: 1.6; }
code { background: var(--gray-100); padding: 2px 7px; border-radius: 4px; font-size: .92em; }

/* ── Progress ────────────────────────────────────────────────────────── */
.progress-container { max-width: 640px; margin-top: 22px; }
.progress-bar-wrapper {
    width: 100%; height: 32px; background: #e5e7eb;
    border-radius: 16px; overflow: hidden;
}
.progress-bar {
    height: 100%; background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 16px; transition: width .3s ease;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .85em; font-weight: 700; min-width: 44px;
    width: 0%;
}
.progress-bar.done { background: linear-gradient(90deg, #059669, #10b981); }
.progress-bar.error { background: #ef4444; width: 100% !important; }
.progress-text {
    margin-top: 14px; font-size: .95em; color: var(--gray-700); text-align: center;
}
.progress-text a { color: var(--blue); font-weight: 600; }

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: space-between; gap: 18px;
    margin-top: 18px; padding: 14px 0; flex-wrap: wrap;
}
.pagination-row { display: flex; align-items: center; gap: 5px; }
.pagination-options {
    display: flex; align-items: center; gap: 10px;
    font-size: .9em; color: var(--gray-500);
}
.pagination-options select {
    padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: 6px;
    font-size: .88em; background: #fff; cursor: pointer;
}
.pagination-options input {
    padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: 6px;
    font-size: .88em; text-align: center;
}
.page-btn {
    padding: 7px 15px; border: 1px solid var(--gray-300); border-radius: 7px;
    background: var(--white); color: var(--gray-700); font-size: .9em;
    cursor: pointer; transition: all .15s; min-width: 38px; text-align: center;
}
.page-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 700; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }
.page-ellipsis { padding: 7px 5px; color: var(--gray-500); font-size: .9em; }

/* ── Empty ───────────────────────────────────────────────────────────── */
.empty-msg { text-align: center; color: var(--gray-500); padding: 52px !important; font-size: .95em; }
