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

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    background: #f5f6fa;
    color: #2c3e50;
    line-height: 1.6;
    min-height: 100vh;
}

/* Nav */
.top-nav {
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    font-size: 20px;
    font-weight: 700;
    color: #e67e22;
    text-decoration: none;
    letter-spacing: 1px;
}
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-link {
    color: #555;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all .2s;
}
.nav-link:hover { background: #fff3e0; color: #e67e22; }
.nav-pdf { background: #e67e22; color: #fff !important; font-weight: 600; }
.nav-pdf:hover { background: #d35400; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 56px); }

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e8e8e8;
    overflow-y: auto;
    padding: 16px;
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.sidebar-header h3 { font-size: 15px; color: #333; }

.location-tree { font-size: 14px; }
.tree-loading { color: #999; font-size: 13px; }

.tree-node { margin-bottom: 2px; }
.tree-node-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
    user-select: none;
}
.tree-node-header:hover { background: #f0f0f0; }
.tree-node-header.active { background: #fff3e0; color: #e67e22; font-weight: 600; }

.tree-toggle {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #999;
    flex-shrink: 0;
    transition: transform .2s;
}
.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.leaf { visibility: hidden; }

.tree-children { padding-left: 16px; }
.tree-children.collapsed { display: none; }

/* Main content */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.content-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
}
.content-header h2 { font-size: 22px; color: #2c3e50; }
.count { font-size: 14px; color: #999; }
.loading { text-align: center; padding: 60px; color: #999; }

/* Restaurant cards */
.restaurant-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.restaurant-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    transition: box-shadow .2s;
    border-left: 4px solid transparent;
}
.restaurant-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.1); }
.restaurant-card.has-controversial { border-left-color: #e17055; }
.restaurant-card.has-expired { border-left-color: #b2bec3; }

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.card-name {
    font-size: 17px;
    font-weight: 700;
    color: #2c3e50;
}
.card-location {
    font-size: 12px;
    color: #888;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 10px;
}

.tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}
.tag-controversial { background: #ffeaa7; color: #d63031; }
.tag-expired { background: #dfe6e9; color: #636e72; }

.card-scores {
    margin-top: 8px;
    font-size: 14px;
    color: #666;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.score-item { display: flex; align-items: center; gap: 4px; }
.score-label { color: #888; }
.score-value { color: #e67e22; font-weight: 700; }
.score-total { font-size: 16px; }

.review-toggle {
    margin-top: 10px;
    font-size: 13px;
    color: #e67e22;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}
.review-toggle:hover { text-decoration: underline; }
.review-count { color: #999; }

.review-list { margin-top: 8px; }
.review-list.collapsed { display: none; }

.review-item {
    padding: 10px 12px;
    margin: 6px 0;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid #eee;
    font-size: 14px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.review-item-body { flex: 1; min-width: 0; }
.review-item p { white-space: pre-wrap; }
.review-edit-btn {
    flex-shrink: 0;
    font-size: 11px;
    padding: 2px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #888;
    cursor: pointer;
    margin-top: 2px;
}
.review-edit-btn:hover { border-color: #e67e22; color: #e67e22; }
.review-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #999;
    display: flex;
    gap: 12px;
}
.review-scores { color: #e67e22; font-weight: 600; font-size: 13px; }

.empty-state { text-align: center; padding: 60px; color: #999; font-size: 15px; }

/* Upload page */
.upload-container {
    max-width: 640px;
    margin: 40px auto;
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.upload-container h2 {
    margin-bottom: 24px;
    color: #2c3e50;
    text-align: center;
    font-size: 22px;
}

.upload-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 14px; font-weight: 600; color: #444; }
.required { color: #e74c3c; }

.form-row { display: flex; gap: 16px; }
.form-group.half { flex: 1; }

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .2s;
    outline: none;
    background: #fafafa;
}
input:focus, select:focus, textarea:focus {
    border-color: #e67e22;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(230,126,34,.1);
}
textarea { resize: vertical; min-height: 80px; }

.select-row { display: flex; gap: 8px; align-items: center; }
.select-row select { flex: 1; }

.new-location-row {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    align-items: flex-start;
    flex-wrap: wrap;
}
.new-location-row > input { flex: 1; min-width: 140px; }

.staged-loc-label {
    font-size: 13px;
    color: #e67e22;
    font-weight: 600;
    background: #fff3e0;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.tree-select-wrapper { position: relative; min-width: 180px; }
.tree-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    background: #fafafa;
    font-size: 14px;
    min-width: 180px;
}
.tree-trigger:hover { border-color: #e67e22; }
.tree-trigger-text { color: #999; }
.tree-trigger-arrow { font-size: 10px; color: #999; }
.tree-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 280px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 200;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 4px;
}
.tree-select-list { list-style: none; padding: 4px 0; margin: 0; }
.tree-select-node { margin: 0; }
.tree-select-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background .1s;
}
.tree-select-item:hover { background: #fff3e0; }
.tree-select-toggle { width: 18px; height: 18px; font-size: 9px; color: #999; text-align: center; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #ddd; border-radius: 3px; background: #f5f5f5; margin-right: 2px; cursor: pointer; line-height: 1; }
.tree-select-toggle:hover { border-color: #e67e22; background: #fff3e0; }
.tree-select-name { white-space: nowrap; cursor: pointer; }
.tree-select-children { display: none; }

.staged-option { color: #e67e22; font-weight: 600; }

.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 200;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #fff3e0; }
.autocomplete-item .item-name { font-weight: 600; }
.autocomplete-item .item-loc { color: #999; font-size: 12px; }
.autocomplete-item.new { color: #e67e22; font-style: italic; }

.form-actions { text-align: center; margin-top: 8px; }

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    transition: all .2s;
}
.btn-sm {
    padding: 4px 12px;
    background: #f0f0f0;
    color: #555;
    font-size: 12px;
}
.btn-sm:hover { background: #e0e0e0; }
.btn-primary { background: #e67e22; color: #fff; padding: 6px 16px; }
.btn-primary:hover { background: #d35400; }
.btn-lg {
    padding: 12px 40px;
    font-size: 16px;
    font-weight: 600;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: #27ae60; color: #fff; }
.toast.error { background: #e74c3c; color: #fff; }

/* Welcome screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}
.welcome-content {
    text-align: center;
    max-width: 500px;
}
.welcome-content h1 {
    font-size: 48px;
    color: #e67e22;
    margin-bottom: 8px;
    letter-spacing: 2px;
}
.welcome-subtitle {
    font-size: 18px;
    color: #888;
    margin-bottom: 24px;
}
.welcome-desc {
    font-size: 15px;
    color: #aaa;
    margin-bottom: 32px;
}
.welcome-stats {
    display: flex;
    gap: 24px;
    justify-content: center;
    color: #999;
    font-size: 14px;
}

/* Location lock */
.location-locked {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f0f7ff;
    border: 1px solid #b3d8ff;
    border-radius: 6px;
    font-size: 13px;
    color: #409eff;
}
.locked-text { flex: 1; }

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f5f6fa;
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,.1);
    width: 360px;
    text-align: center;
}
.login-box h2 { margin-bottom: 24px; color: #2c3e50; }
.login-box input[type="password"] { width: 100%; }
.login-box .btn-lg { width: 100%; margin-top: 16px; }
.login-error { color: #e74c3c; font-size: 13px; margin-top: 8px; min-height: 20px; }

/* Admin layout */
.admin-layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 2px solid #e67e22;
    margin-bottom: 20px;
}
.admin-header h2 { color: #e67e22; }
.admin-body { display: flex; gap: 0; min-height: 70vh; }
.admin-left { width: 320px; min-width: 200px; flex-shrink: 0; }
.admin-resize-handle {
    width: 8px;
    min-width: 8px;
    cursor: ew-resize;
    background: #ddd;
    flex-shrink: 0;
    border-left: 2px solid #ccc;
    border-right: 2px solid #ccc;
}
.admin-resize-handle:hover,
.admin-resize-handle.active { background: #e67e22; border-color: #d35400; }
.admin-right { flex: 1; min-width: 0; }
.admin-left h3, .admin-right h3 { margin-bottom: 12px; color: #444; }
.admin-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}
.admin-location-tree {
    font-size: 14px;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 12px;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    background: #fff;
    padding: 4px 0;
}
.admin-loc-node { margin: 0; }
.admin-loc-header {
    display: flex;
    align-items: center;
    padding: 7px 8px 7px 4px;
    border-bottom: 1px solid #f5f5f5;
    min-width: 0;
}
.admin-loc-header:hover { background: #f8f9fa; }
.admin-loc-header .tree-toggle {
    width: 20px; height: 20px;
    font-size: 9px; color: #999;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #e0e0e0; border-radius: 3px;
    background: #fafafa;
    flex-shrink: 0;
    margin-right: 6px;
    cursor: pointer;
}
.admin-loc-header .tree-toggle:hover { border-color: #e67e22; background: #fff3e0; }
.admin-loc-name {
    flex: 1 1 auto;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 40px;
}
.admin-loc-name .loc-id {
    font-size: 11px;
    color: #bbb;
    font-weight: 400;
    margin-left: 4px;
}
.admin-loc-name.active {
    color: #e67e22;
    font-weight: 700;
}
.admin-loc-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}
.admin-loc-actions button {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    color: #666;
    white-space: nowrap;
}
.admin-loc-actions button:hover { background: #f0f0f0; border-color: #ccc; }
.admin-loc-children { padding-left: 20px; }
.admin-loc-children.collapsed { display: none; }

.admin-add-loc {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.admin-add-loc input, .admin-add-loc select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}

.admin-restaurant-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
}
.admin-restaurant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.admin-restaurant-header h4 { font-size: 15px; }
.admin-restaurant-meta { font-size: 12px; color: #888; margin-top: 2px; }
.admin-restaurant-body { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #eee; }
.admin-restaurant-body.collapsed { display: none; }
.admin-review-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 8px;
    margin: 4px 0;
    background: #fafafa;
    border-radius: 4px;
    font-size: 13px;
}
.admin-review-info { flex: 1; }
.admin-review-info .meta { font-size: 11px; color: #999; }
.admin-review-delete {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}
.admin-restaurant-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}
.admin-restaurant-actions button {
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}
.admin-restaurant-actions button:hover { background: #f0f0f0; }
.admin-restaurant-actions .btn-danger { border-color: #e74c3c; color: #e74c3c; }
.admin-restaurant-actions .btn-danger:hover { background: #fde8e8; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box h3 { margin-bottom: 16px; }
.modal-box .form-group { margin-bottom: 12px; }
.modal-box .form-group label { font-size: 13px; margin-bottom: 4px; }
.modal-box input, .modal-box select { width: 100%; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button {
    padding: 8px 20px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
}
.modal-actions .btn-save { background: #e67e22; color: #fff; border-color: #e67e22; }
.modal-actions .btn-save:hover { background: #d35400; }

.btn-delete { background: #e74c3c; color: #fff; border: none; }
.btn-delete:hover { background: #c0392b; }

/* Backup page */
.backup-container { max-width: 800px; margin: 0 auto; }
.backup-section { background: #fff; border-radius: 10px; padding: 20px 24px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.backup-section h3 { margin-bottom: 8px; color: #2c3e50; }
.backup-desc { font-size: 13px; color: #999; margin-bottom: 12px; }
.backup-status { font-size: 13px; color: #27ae60; margin-left: 12px; }
.backup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}
.backup-item:last-child { border-bottom: none; }
.backup-info { display: flex; flex-direction: column; }
.backup-name { font-size: 14px; font-weight: 600; color: #333; font-family: monospace; }
.backup-meta { font-size: 12px; color: #999; }
.backup-actions { display: flex; gap: 8px; }
.backup-actions button {
    padding: 4px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 12px;
}
.btn-restore { background: #e67e22; color: #fff; }
.btn-restore:hover { background: #d35400; }

/* Sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 290;
}
.sidebar-overlay.show { display: block; }

/* Hamburger */
.hamburger {
    display: none;
    width: 36px; height: 36px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #555;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
}
.hamburger:hover { background: #f0f0f0; }

/* Responsive */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .hamburger { display: inline-flex; }

    .top-nav { padding: 0 12px; height: 48px; }
    .top-nav .nav-brand { font-size: 17px; }
    .nav-link { font-size: 12px; padding: 4px 8px; }
    .nav-pdf { font-size: 12px; padding: 4px 10px; }

    .main-container { padding-top: 48px; }

    .layout { flex-direction: column; position: relative; }

    .sidebar {
        position: fixed;
        top: 48px;
        left: 0;
        width: 280px;
        max-width: 82vw;
        height: calc(100vh - 48px);
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0,0,0,0.18);
        overflow-y: auto;
        padding: 12px;
    }
    .sidebar.open { transform: translateX(0); }

    .content { padding: 16px; }

    .restaurant-grid { gap: 8px; }
    .restaurant-card { padding: 12px 14px; border-radius: 8px; }
    .card-name { font-size: 15px; }
    .card-scores { font-size: 13px; gap: 10px; flex-wrap: wrap; }

    .review-item { font-size: 13px; padding: 8px 10px; }

    .form-row { flex-direction: column; }
    .upload-container { margin: 12px; padding: 20px 16px; }
    .upload-container h2 { font-size: 18px; }

    .welcome-content h1 { font-size: 36px; }
    .welcome-desc { font-size: 14px; padding: 0 20px; }

    .admin-body { flex-direction: column; }
    .admin-left { width: 100%; min-width: 100%; }
    .admin-header { flex-wrap: wrap; gap: 8px; }
    .modal-box { min-width: auto; width: 92vw; max-height: 85vh; }

    .login-box { width: 90%; padding: 28px 20px; }

    .new-location-row { flex-direction: column; }
    .tree-select-wrapper { min-width: 100%; }

    .select-row { flex-wrap: wrap; }
    .select-row select { min-width: 160px; }

    .backup-item { flex-direction: column; align-items: flex-start; gap: 8px; }
}
