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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
    line-height: 1.6;
}

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

.sidebar {
    width: 64px;
    background: #1e293b;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width 0.25s ease;
    overflow: hidden;
}

.sidebar.expanded {
    width: 200px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
    margin-bottom: 20px;
    min-height: 40px;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #60a5fa;
    text-decoration: none;
    border-radius: 10px;
    transition: background 0.2s;
}

.sidebar-logo:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-logo svg {
    width: 26px;
    height: 26px;
}

.sidebar-brand {
    color: #e2e8f0;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar.expanded .sidebar-brand {
    opacity: 1;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    padding: 0 10px;
    width: 100%;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 6px;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
}

.sidebar-item,
.sidebar-toggle {
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    font-size: 0.9rem;
    font-family: inherit;
    white-space: nowrap;
}

.sidebar-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-icon svg {
    width: 22px;
    height: 22px;
}

.sidebar-label {
    opacity: 0;
    transition: opacity 0.2s;
    overflow: hidden;
}

.sidebar.expanded .sidebar-label {
    opacity: 1;
}

.sidebar-item:hover,
.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.sidebar-item.active {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

.sidebar-item:active,
.sidebar-toggle:active {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-toggle {
    color: #64748b;
}

.sidebar-toggle-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.sidebar.expanded .sidebar-toggle-icon {
    transform: rotate(180deg);
}

.layout-main {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.layout-main > main {
    flex: 1;
}

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

.site-header {
    background: #1e3a5f;
    color: #fff;
    padding: 20px 0;
    margin-bottom: 32px;
}

.site-header h1 {
    font-size: 1.5rem;
}

.site-header-hero {
    text-align: center;
    padding: 36px 0;
}

.site-header-hero h1 {
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: #1e3a5f;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-clear-wrap {
    position: relative;
    width: 100%;
}

.input-clear-wrap input[type="text"] {
    width: 100%;
    padding-right: 32px;
}

.input-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: #c7c7cc;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, background 0.15s;
}

.input-clear-btn svg {
    display: block;
    width: 8px;
    height: 8px;
}

.input-clear-wrap.is-focused.has-value .input-clear-btn {
    opacity: 1;
    pointer-events: auto;
}

.input-clear-btn:hover {
    background: #aeaeb2;
}

.input-clear-btn:active {
    background: #8e8e93;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

.form-group input[type="file"] {
    font-size: 0.95rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

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

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

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

.btn-edit {
    background: #eff6ff;
    color: #2563eb;
}

.btn-edit:hover {
    background: #dbeafe;
}

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

.btn-danger:hover {
    background: #fecaca;
}

.required {
    color: #ef4444;
}

.text-muted {
    color: #6b7280;
    font-size: 0.85rem;
}

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

.current-photo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.thumb-preview {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.list-search {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}

.list-search .input-clear-wrap {
    flex: 1;
}

.list-search input[type="text"] {
    width: 100%;
    padding: 8px 32px 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
}

.list-search input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
}

.table-wrap {
    overflow-x: auto;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.user-table th,
.user-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}

.user-table th {
    background: #f9fafb;
    color: #6b7280;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
}

.user-table tbody tr:hover {
    background: #f9fafb;
}

.user-table .row-editing {
    background: #eff6ff;
}

.user-table .thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    display: block;
}

.user-table .thumb-empty {
    color: #9ca3af;
}

.user-table .col-remark {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-table .col-actions {
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.col-actions .btn-sm {
    margin-right: 4px;
}

.col-actions form.inline-form {
    display: inline-block;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.search-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.search-bar .form-group {
    flex: 1;
    margin-bottom: 0;
}

.results-count {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.user-grid {
    display: grid;
    gap: 16px;
}

.user-card {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 16px;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
}

.user-photo {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #e5e7eb;
}

.zoomable-photo {
    cursor: zoom-in;
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-lightbox[hidden] {
    display: none;
}

.photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.photo-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    padding: 12px;
}

.photo-lightbox-content img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.photo-lightbox-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #374151;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.photo-lightbox-close:hover {
    background: #f3f4f6;
}

.user-table .thumb.zoomable-photo {
    cursor: zoom-in;
}

.user-photo-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 8px;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.8rem;
}

.user-info dt {
    font-weight: 600;
    color: #6b7280;
    font-size: 0.85rem;
    margin-top: 6px;
}

.user-info dt:first-child {
    margin-top: 0;
}

.user-info dd {
    font-size: 1rem;
    color: #1f2937;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
}

.empty-state-default {
    padding: 80px 20px;
}

.empty-state-title {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 0.9rem;
    color: #9ca3af;
}

.site-footer {
    text-align: center;
    padding: 24px 0;
    color: #9ca3af;
    font-size: 0.85rem;
    margin-top: auto;
}

.page-search .card {
    
    margin-left: auto;
    margin-right: auto;
}

.page-search .card h2,
.page-search .results-count {
    text-align: center;
}

.page-search .user-grid {
    margin: 0 auto;
}

.search-loading {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.search-loading p {
    margin-top: 12px;
    font-size: 0.95rem;
}

.search-loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: search-spin 0.8s linear infinite;
}

@keyframes search-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 600px) {
    .site-header-hero h1 {
        font-size: 2rem;
        letter-spacing: 0.04em;
    }

    .site-header-hero {
        padding: 28px 0;
    }

    .sidebar {
        width: 52px;
        padding: 12px 0;
    }

    .sidebar.expanded {
        width: 180px;
    }

    .sidebar-header,
    .sidebar-nav,
    .sidebar-bottom {
        padding-left: 6px;
        padding-right: 6px;
    }

    .sidebar-item,
    .sidebar-toggle {
        height: 40px;
        padding: 0 8px;
    }

    .sidebar-icon svg,
    .sidebar-toggle-icon {
        width: 20px;
        height: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .user-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .user-photo,
    .user-photo-placeholder {
        margin: 0 auto;
    }

    .user-table {
        font-size: 0.85rem;
    }

    .user-table th,
    .user-table td {
        padding: 5px 6px;
    }

    .list-search {
        flex-wrap: wrap;
    }
}
