:root {
    --primary: #2a75bb;
    --primary-dark: #1f5a91;
    --accent: #ffcb05;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --border: #d8dde2;
    --text: #2b2f33;
    --text-muted: #6b7280;
    --success: #2e7d32;
    --success-bg: #e8f5e9;
    --error: #c62828;
    --error-bg: #fdecea;
    --radius: 6px;
    --card-ratio: 2.5 / 3.5; /* standard trading card aspect ratio (portrait) */
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: #fff;
    border-bottom: 3px solid var(--accent);
    padding: 14px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.logo { text-decoration: none; display: flex; align-items: center; gap: 14px; }
.logo-img { height: 72px; width: auto; display: block; flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.logo-name { font-size: 2rem; font-weight: 800; line-height: 1; letter-spacing: -0.5px; }
.logo-poke  { color: var(--primary); }
.logo-vault { color: #c49000; }
.logo-tag { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.site-header nav a {
    color: var(--text);
    text-decoration: none;
    margin-left: 18px;
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0.75;
    transition: opacity 0.15s, color 0.15s;
}
.site-header nav a:hover { opacity: 1; color: var(--primary); }

/* Main */
main { padding: 24px 20px 60px; }

h1, h2, h3 { margin-top: 0; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.95rem;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a5d6a7; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #ef9a9a; }

/* Cards / panels */
.panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1 / -1; }
label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: var(--text);
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
    width: 100%;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(42,117,187,0.15);
}

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

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.description-preview {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fafbfc;
    font-size: 0.95rem;
    min-height: 40px;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    grid-column: 1 / -1;
}
fieldset legend { font-weight: 700; padding: 0 6px; }
.grading-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 12px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 18px;
    border-radius: var(--radius);
    border: 1px solid var(--primary);
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    box-sizing: border-box;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: #eef4fb; }
.btn-danger { background: #fff; color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error-bg); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 4px 8px; font-size: 0.85rem; text-decoration: underline; }
.btn-link:hover { color: var(--primary-dark); }
.btn-link.danger { color: var(--error); }
.btn-link.danger:hover { color: #b71c1c; }
.actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; }
.actions form { display: contents; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.82rem;
    vertical-align: middle;
}
th { background: #eef2f5; font-weight: 700; }
tr:hover td { background: #fafcfe; }
.thumb {
    width: 32px;
    aspect-ratio: var(--card-ratio);
    object-fit: cover; border-radius: 3px;
    border: 1px solid var(--border); background: #fff;
}
.no-image {
    width: 32px; aspect-ratio: var(--card-ratio); border-radius: 3px; border: 1px solid var(--border);
    background: #f0f2f4; display: flex; align-items: center; justify-content: center;
    font-size: 0.55rem; color: var(--text-muted); text-align: center; padding: 2px;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
}
.badge-inv  { background: #2e7d32; }
.badge-hold { background: #1565c0; }
.badge-sold { background: #6b7280; }
.badge-phash { background: #e8eaf6; color: #283593; border: 1px solid #9fa8da; }
.badge-phash-verified { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.badge-1ed {
    display: inline-block;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 1px 5px;
    border-radius: 4px;
    background: #fef08a;
    color: #713f12;
    border: 1px solid #fbbf24;
    vertical-align: middle;
    margin-left: 4px;
    white-space: nowrap;
}

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: end;
}
.filter-bar .form-group { min-width: 120px; flex: 1; max-width: 220px; }
.filter-bar .form-group:last-child { flex: none; max-width: none; }
.filter-bar label { margin-bottom: 4px; }

/* Image gallery in form/detail */
.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}
.image-gallery .img-wrap {
    position: relative;
    width: 100px;
}
.image-gallery img {
    width: 100px; aspect-ratio: var(--card-ratio); object-fit: cover; border-radius: var(--radius);
    border: 1px solid var(--border);
}
.image-gallery .primary-tag {
    position: absolute; top: 4px; left: 4px;
    background: var(--accent); color: #3a2c00;
    font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 4px;
}
.image-gallery .img-actions {
    display: flex; justify-content: space-between; margin-top: 4px; font-size: 0.75rem;
}
.image-gallery .img-actions a { color: var(--primary); text-decoration: none; }
.image-gallery .img-actions a.danger { color: var(--error); }

/* Detail view */
.detail-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 800px) {
    .detail-grid { grid-template-columns: 1fr; }
}
.detail-main-image {
    width: 100%; max-width: 280px; border-radius: var(--radius); border: 1px solid var(--border);
    object-fit: cover; aspect-ratio: var(--card-ratio); background: #fff;
}
.detail-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.detail-thumbs img { width: 52px; aspect-ratio: var(--card-ratio); object-fit: cover; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; }

/* Detail header */
.detail-header {
    background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
    border-top: 3px solid var(--primary);
}
.detail-header h1 { margin: 0 0 10px; font-size: 1.1rem; line-height: 1.35; color: var(--text); }
.detail-headline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-price { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.detail-pl {
    font-size: 0.85rem; font-weight: 700;
    padding: 3px 10px; border-radius: 999px;
    background: var(--bg); border: 1px solid var(--border);
}

/* Detail field grid */
.detail-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.detail-section-title {
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: .1em; color: var(--primary);
    margin-bottom: 12px; padding-bottom: 6px;
    border-bottom: 2px solid var(--accent);
}
.detail-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.df-cell {
    background: var(--bg);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.df-cell.df-wide { grid-column: span 2; }
.df-label {
    font-size: 0.68rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .07em;
}
.df-value {
    font-size: 1rem; font-weight: 600; color: var(--text);
    word-break: break-word; line-height: 1.3;
}
.df-mono { font-family: monospace; font-size: 0.9rem; font-weight: 400; }
.df-grade { font-size: 1.25rem; font-weight: 800; color: var(--primary); }
.df-note {
    background: var(--bg); border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 10px 14px; font-size: 0.92rem; color: var(--text);
    white-space: pre-wrap; line-height: 1.6;
}

/* Barcode */
.barcode-wrap { text-align: center; margin-top: 12px; }
.barcode-wrap svg { max-width: 100%; height: 60px; }
.barcode-code { font-family: monospace; letter-spacing: 2px; margin-top: 4px; font-size: 0.85rem; }

/* Pagination */
.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none; color: var(--text); font-size: 0.9rem;
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Quick Sale button */
.btn-sale {
    background: #2e7d32; color: #fff; border-color: #2e7d32;
    font-weight: 700;
}
.btn-sale:hover { background: #1b5e20; border-color: #1b5e20; }

/* Quick Sale modal */
.qs-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.5);
    align-items: center; justify-content: center;
}
.qs-overlay.open { display: flex; }
.qs-modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    width: 100%; max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    overflow: hidden;
}
.qs-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; background: #2e7d32; color: #fff;
}
.qs-header h2 { margin: 0; font-size: 1.1rem; }
.qs-close {
    background: none; border: none; color: #fff;
    font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0 4px;
}
.qs-item-title {
    margin: 0; padding: 12px 20px;
    font-size: 0.88rem; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qs-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.qs-methods { display: flex; gap: 8px; margin-top: 4px; }
.qs-method-btn {
    flex: 1; cursor: pointer;
}
.qs-method-btn input { display: none; }
.qs-method-btn span {
    display: block; text-align: center;
    padding: 8px 4px; border: 2px solid var(--border);
    border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
    color: var(--text-muted); transition: all 0.15s;
}
.qs-method-btn input:checked + span {
    border-color: #2e7d32; color: #2e7d32; background: #f0faf0;
}
.qs-footer {
    display: flex; gap: 10px; padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* Scan page */
.scan-box {
    max-width: 480px; margin: 0 auto; text-align: center;
}
.scan-box input { font-size: 1.4rem; text-align: center; padding: 16px; }
.scan-result { margin-top: 20px; }

/* Lookup management */
.lookup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.lookup-list { list-style: none; padding: 0; margin: 10px 0; }
.lookup-list li {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem;
}
.lookup-list form { display: inline; }

.text-muted { color: var(--text-muted); font-size: 0.85rem; }
