:root {
    --primary: #1a73e8;
    --primary-dark: #1558b0;
    --success: #34a853;
    --danger: #ea4335;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #202124;
    --muted: #5f6368;
    --border: #e0e3eb;
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body.app-body,
body.login-page {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-header {
    background: linear-gradient(135deg, var(--primary), #4285f4);
    color: #fff;
}

.app-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.app-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.app-nav {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.app-nav-link {
    white-space: nowrap;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--muted);
    background: #f1f3f4;
    font-size: 0.9rem;
}

.app-nav-link.active {
    background: rgba(26, 115, 232, 0.12);
    color: var(--primary);
    font-weight: 600;
}

.app-main {
    padding: 1rem;
    max-width: 720px;
    margin: 0 auto;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.status-card,
.door-card,
.log-item,
.user-item,
.form-card {
    background: var(--card);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(32, 33, 36, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.status-label,
.door-name {
    font-weight: 700;
}

.status-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.status-meta,
.door-status,
.log-meta,
.user-meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.door-card {
    margin-bottom: 0.85rem;
}

.door-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
}

.door-status.open {
    color: var(--success);
}

.door-status.closed {
    color: var(--muted);
}

.door-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #dadce0;
}

.door-indicator.is-open {
    background: var(--success);
    box-shadow: 0 0 0 6px rgba(52, 168, 83, 0.15);
}

.door-indicator.has-alarm {
    background: var(--danger);
    box-shadow: 0 0 0 6px rgba(234, 67, 53, 0.15);
}

.door-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.log-list .log-item,
.user-list .user-item {
    margin-bottom: 0.75rem;
}

.log-message,
.log-ip {
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

.user-name {
    font-weight: 700;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    min-height: 100vh;
    background: linear-gradient(180deg, #e8f0fe 0%, #f5f7fb 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 16px 40px rgba(26, 115, 232, 0.12);
}

.login-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
}

.login-desc {
    color: var(--muted);
    margin-top: 0.25rem;
}

.login-brand {
    margin-bottom: 1.25rem;
}

.login-footer {
    margin-top: 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
}

.captcha-panel {
    user-select: none;
}

.captcha-bg {
    position: relative;
    width: 100%;
    max-width: 280px;
    height: 120px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    margin-bottom: 0.75rem;
}

.captcha-hole,
.captcha-piece {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    top: 38px;
}

.captcha-hole {
    left: 120px;
    background: rgba(0, 0, 0, 0.25);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.captcha-piece {
    left: 18px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    cursor: grab;
    touch-action: none;
}

.captcha-track {
    position: relative;
    width: 100%;
    max-width: 280px;
    height: 44px;
    background: #eef2f7;
    border-radius: 999px;
    overflow: hidden;
}

.captcha-track-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: rgba(26, 115, 232, 0.15);
}

.captcha-slider {
    position: absolute;
    left: 0;
    top: 2px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    z-index: 2;
}

.captcha-slider.verified {
    background: var(--success);
}

.captcha-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.captcha-panel.verified .captcha-hint {
    color: var(--success);
    font-weight: 600;
}

.controller-block + .controller-block {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

@media (max-width: 480px) {
    .door-actions {
        grid-template-columns: 1fr;
    }

    .app-main {
        padding: 0.85rem;
    }
}
