:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --bg: #f1f5f9;
    --card: #ffffff;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --green: #10b981;
    --amber: #f59e0b;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

button, input, select { font-family: inherit; }
.hidden { display: none !important; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: #eef2f7;
    color: #334155;
    transition: background .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .25); }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: #334155; }
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, #e0ecff 0%, #f1f5f9 45%, #f8fafc 100%);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .14);
    padding: 34px 30px 30px;
}
.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(160deg, #3b82f6, #2563eb);
    color: #fff;
    font-weight: 700;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 8px 20px rgba(37, 99, 235, .3);
}
.login-card h1 { font-size: 21px; margin: 0 0 6px; letter-spacing: -.01em; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: #475569; font-weight: 600; margin-bottom: 6px; }
.field input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 11px;
    font-size: 15px;
    background: #f8fafc;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: rgba(37, 99, 235, .55); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); background: #fff; }
.login-error { color: #dc2626; font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.login-card .btn-primary { height: 48px; font-size: 16px; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px 20px;
    background: linear-gradient(120deg, #1e3a8a, #2563eb 60%, #3b82f6);
    color: #fff;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .15);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.brand-mark {
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 10px;
    padding: 5px 9px;
    font-weight: 700;
    font-size: 14px;
}
.brand-text { font-weight: 600; font-size: 15px; letter-spacing: .02em; }
.overall { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.overall .bar { flex: 1; max-width: 420px; }
.bar { height: 8px; background: rgba(255, 255, 255, .25); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #86efac, #34d399); border-radius: 999px; transition: width .3s; }
#overallText { font-size: 13px; white-space: nowrap; opacity: .95; }
.userbox { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#userInfo { font-size: 13px; margin-right: 4px; white-space: nowrap; }
.userbox .btn-ghost { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff; }
.userbox .btn-ghost:hover { background: rgba(255, 255, 255, .24); }

.layout { display: flex; align-items: flex-start; gap: 16px; padding: 16px 20px 40px; }
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow: auto;
}
.side-title { padding: 14px 16px 8px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .08em; }
.side-list { padding: 0 8px 10px; }
.building-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: #1e293b;
    transition: background .15s;
}
.building-item:hover { background: #f1f5f9; }
.building-item.active { background: #e0ecff; color: var(--blue-dark); }
.building-item .cnt { font-size: 12px; font-weight: 500; color: var(--muted); }
.building-item.active .cnt { color: var(--blue-dark); }
.floor-list { padding: 2px 0 8px 10px; }
.floor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    color: #334155;
}
.floor-item:hover { background: #f1f5f9; }
.floor-item.active { background: #dbeafe; color: var(--blue-dark); font-weight: 700; }
.floor-item .cnt { font-size: 12px; color: var(--muted); }
.floor-item.active .cnt { color: var(--blue-dark); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 14px;
}
.toolbar .title { font-size: 16px; font-weight: 700; margin-right: 4px; }
.toolbar .sub { color: var(--muted); font-size: 12px; margin-right: auto; }
.search-box { position: relative; }
.search-box input {
    width: 230px;
    height: 36px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f8fafc;
    outline: none;
    font-size: 13px;
}
.search-box input:focus { border-color: rgba(37, 99, 235, .5); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); background: #fff; }
.search-box::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: .6;
}
.filter-group { display: inline-flex; background: #eef2f7; border-radius: 999px; padding: 3px; }
.filter-group button {
    border: none;
    background: transparent;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}
.filter-group button.active { background: #fff; color: var(--blue-dark); box-shadow: 0 1px 4px rgba(15, 23, 42, .12); }
.progress-chip { font-size: 13px; color: #334155; font-weight: 600; background: #f1f5f9; border-radius: 999px; padding: 6px 12px; }
.progress-chip b { color: var(--blue-dark); }

.rooms-area {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.room-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    position: relative;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.room-card.done { border-color: #a7f3d0; }
.room-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.room-card.dragover { border-color: var(--blue); background: #f0f7ff; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.floor-tag { font-size: 11px; color: var(--muted); background: #f1f5f9; border-radius: 6px; padding: 2px 6px; }
.room-meta { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.room-status { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.status-dot.ok { background: var(--green); }
.status-text { color: #64748b; }
.status-text.ok { color: #047857; font-weight: 600; }
.room-thumb {
    margin-top: 10px;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 10px;
    background: #f1f5f9 center/cover no-repeat;
    border: 1px solid var(--line);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.room-thumb.empty { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 12px; }
.room-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room-actions { display: flex; gap: 6px; margin-top: 10px; }
.room-actions .btn { flex: 1; padding: 7px 8px; font-size: 12.5px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 0 10px; grid-column: 1 / -1; }
.pagination span { color: var(--muted); font-size: 13px; }
.empty-state { grid-column: 1 / -1; text-align: center; color: #94a3b8; padding: 60px 20px; font-size: 14px; }

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 60;
}
.modal-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
    width: 100%;
    max-width: 640px;
    max-height: 86vh;
    overflow: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.icon-btn { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.viewer-img { width: 100%; border-radius: 12px; display: block; }

.batch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.batch-table th, .batch-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.batch-table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.batch-table select { height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0 8px; max-width: 180px; }
.batch-file { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-ok { color: #047857; font-weight: 600; }
.match-bad { color: #b45309; font-weight: 600; }
.batch-hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.7; }
.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 26px 16px;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    background: #f8fafc;
    transition: border-color .15s, background .15s;
}
.drop-zone.dragover { border-color: var(--blue); background: #f0f7ff; }

.upload-float { position: fixed; right: 22px; bottom: 22px; z-index: 70; }
.upload-float-inner {
    background: #0f172a;
    color: #fff;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .35);
    min-width: 240px;
}
.upload-float .bar { margin-top: 8px; background: rgba(255, 255, 255, .2); }
.upload-float .bar i { background: linear-gradient(90deg, #60a5fa, #38bdf8); }
#uploadText { font-size: 13px; }

.toast-wrap { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
    background: rgba(15, 23, 42, .92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .25);
    animation: toastIn .18s ease-out;
    max-width: 86vw;
}
.toast.success { background: rgba(4, 120, 87, .95); }
.toast.error { background: rgba(185, 28, 28, .95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
    .brand { min-width: 0; }
    .brand-text { display: none; }
    .overall { order: 3; width: 100%; }
    .overall .bar { max-width: none; }
    .userbox { margin-left: auto; }
    .layout { flex-direction: column; padding: 12px; }
    .sidebar { position: static; width: 100%; max-height: none; }
    .side-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 12px; }
    .building-item { padding: 8px 12px; border-radius: 999px; background: #f1f5f9; }
    .floor-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 10px; }
    .floor-item { padding: 6px 12px; border-radius: 999px; background: #f8fafc; }
    .rooms-area { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .room-name { font-size: 15px; }
    .search-box input { width: 100%; }
    .toolbar .search-box { flex: 1; }
    .toolbar .title { width: 100%; }
}
