:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #181d1f;
    --bg-card: #0f3460;
    --bg-input: #1e2a45;
    --bg-modal: #1a1f36;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-muted: #6c7a8d;
    --accent: #4f8ef7;
    --accent-hover: #3a7de6;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #27ae60;
    --border: #2c3e5a;
    --border-light: #3a4f6a;
    --shadow: rgba(0, 0, 0, 0.4);
    --toolbar-h: 32px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    min-width: 400px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Form controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-label.required::after {
    content: ' *';
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 600px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px var(--shadow);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 24px;
    padding: 2px 6px;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px var(--shadow);
    animation: toastIn 0.2s ease;
    max-width: 320px;
}

.toast-success {
    background: #1d4a2e;
    border: 1px solid #27ae60;
    color: #6fcf97;
}

.toast-error {
    background: #4a1d1d;
    border: 1px solid var(--danger);
    color: #eb5757;
}

.toast-info {
    background: #1a2e4a;
    border: 1px solid #3a8fcb;
    color: #7eb8f7;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Category chip */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}

/* Price */
.price-group {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
}

/* Date picker */
.date-picker-popup {
    position: absolute;
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1100;
    padding: 12px;
    width: 240px;
}

.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.date-picker-year {
    font-weight: 600;
    font-size: 14px;
}

.date-picker-nav {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 16px;
}

.date-picker-nav:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.date-picker-months {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.date-picker-month {
    padding: 6px 4px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
    background: none;
    border: 1px solid transparent;
    color: var(--text-primary);
    transition: background 0.1s;
}

.date-picker-month:hover {
    background: var(--bg-input);
    border-color: var(--border);
}

.date-picker-month.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Confirm dialog */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.active {
    display: flex;
}

.confirm-box {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    width: 320px;
    box-shadow: 0 12px 40px var(--shadow);
}

.confirm-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Responsive grid form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

/* Lightbox */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
}

.lightbox-spinner {
    color: rgba(255, 255, 255, 0.7);
    font-size: 36px;
}

/* Search bar (unified header+toolbar for user page) */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
}

.search-bar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    flex-wrap: wrap;
}

.search-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.search-bar .form-control {
    height: var(--toolbar-h);
    padding: 0 10px;
    font-size: 13px;
}

.search-bar .btn {
    height: var(--toolbar-h);
    padding: 0 12px;
    font-size: 13px;
}

.search-bar select.form-control {
    padding-top: 0;
    padding-bottom: 0;
}

.search-select { width: 110px; }
.search-input  { width: 140px; }

/* Google Sign-In button (branding guidelines: dark theme) */
.btn-google-signin {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #131314;
    border: 1px solid #8E918F;
    border-radius: 4px;
    padding: 0 12px;
    height: var(--toolbar-h);
    color: #E3E3E3;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-google-signin:hover {
    background: #1e1e20;
    color: #E3E3E3;
}

/* Profile / logout button */
.btn-profile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.btn-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.btn-profile:hover {
    border-color: var(--border-light);
}

/* Toolbar (shared between admin and user pages) */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.toolbar .form-control {
    height: var(--toolbar-h);
    padding: 0 10px;
    font-size: 13px;
}

.toolbar .btn {
    height: var(--toolbar-h);
    padding: 0 12px;
    font-size: 13px;
}

.toolbar select.form-control {
    padding-top: 0;
    padding-bottom: 0;
}

.toolbar .search-select { width: 120px; }
.toolbar .search-input  { width: 150px; }

/* Responsive: tablet & mobile collapse search bar */
.search-pc-only { display: contents; }
.search-mobile-only { display: none; }

/* Box art cell */
.cell-boxart {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 100%;
    padding: 0;
    overflow: hidden;
}

.cell-boxart img {
    max-width: 100px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.cell-boxart-placeholder {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* Merged name cell (shared between admin and user grids) */
.cell-name {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    gap: 3px;
    padding: 4px 0;
    overflow: hidden;
    min-width: 0;
    width: 100%;
}

.name-line1 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    overflow: hidden;
}

.name-line2 {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    flex-wrap: nowrap;
    overflow: hidden;
}

.search-highlight {
    background: #26e8fa;
    color: #111;
    border-radius: 2px;
    padding: 0 1px;
    font-weight: bold;
}

@media (max-width: 1023px) {
    .search-pc-only { display: none; }
    .search-mobile-only { display: contents; }
    .search-input-kw { width: 180px; }
    .btn-google-signin-label { display: none; }
}
