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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ========== Layout ========== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 36px 0 12px;
}

header h1 {
    font-size: 26px;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

header p {
    color: #999;
    font-size: 13px;
    margin-top: 6px;
}

/* ========== Navbar ========== */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    margin-bottom: 8px;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    background: #e8ecf1;
    border-radius: 10px;
    padding: 3px;
}

.tab-btn {
    padding: 8px 22px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #fff;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.tab-btn:hover:not(.active) {
    color: #333;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #888;
}

.nav-right .user-name {
    color: #555;
    font-weight: 500;
}

.nav-right .btn-text {
    background: none;
    border: none;
    color: #4f8ef7;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.nav-right .btn-text:hover {
    background: #edf3ff;
}

.nav-right .btn-text.logout {
    color: #999;
}

.nav-right .btn-text.logout:hover {
    color: #ff3b30;
    background: #fff0f0;
}

/* ========== Tab Content ========== */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== Card ========== */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1a1a1a;
}

/* ========== Form ========== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-group label {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #4f8ef7;
    box-shadow: 0 0 0 3px rgba(79,142,247,0.1);
}

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

/* ========== Buttons ========== */
.btn {
    padding: 9px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: #4f8ef7; color: #fff; }
.btn-primary:hover { background: #3a7be0; }

.btn-success { background: #34c759; color: #fff; }
.btn-success:hover { background: #2db84e; }

.btn-danger { background: #ff3b30; color: #fff; }
.btn-danger:hover { background: #e0342c; }

.btn-ghost {
    background: #f5f5f5;
    color: #666;
}

.btn-ghost:hover { background: #eee; }

.btn-sm { padding: 6px 14px; font-size: 12px; }

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

.btn-install {
    background: #4f8ef7;
    color: #fff;
    padding: 12px 36px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-install:hover { background: #3a7be0; transform: translateY(-1px); }
.btn-install.android { background: #34c759; }
.btn-install.android:hover { background: #2db84e; }

/* ========== Upload Area ========== */
.upload-area {
    border: 2px dashed #d0d7e2;
    border-radius: 12px;
    padding: 36px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #4f8ef7;
    background: #f7faff;
}

.upload-area .icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.upload-area p {
    color: #888;
    font-size: 14px;
}

.upload-area .hint {
    font-size: 12px;
    color: #bbb;
    margin-top: 6px;
}

/* ========== Upload Meta Form ========== */
.upload-meta {
    display: none;
    margin-bottom: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #eee;
}

.upload-meta.show { display: block; }

.upload-meta .file-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 14px;
}

.file-badge.android { background: #e8f5e9; color: #2e7d32; }
.file-badge.ios { background: #e3f2fd; color: #1565c0; }

/* ========== Progress ========== */
.progress-wrap {
    display: none;
    margin-bottom: 16px;
}

.progress-wrap.show { display: block; }

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
    margin-bottom: 6px;
}

.progress-bar {
    height: 5px;
    background: #e8ecf1;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, #4f8ef7, #34c759);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s;
}

/* ========== App Cards (Download Page) ========== */
.app-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.app-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    gap: 20px;
    transition: box-shadow 0.2s;
}

.app-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.app-card-icon {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.app-card-icon.android { background: #e8f5e9; }
.app-card-icon.ios { background: #e3f2fd; }

.app-card-body {
    flex: 1;
    min-width: 0;
}

.app-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.app-card-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-card-version {
    font-size: 11px;
    color: #999;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.app-card-info {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
}

.app-card-info span + span::before {
    content: ' · ';
}

.app-card-changelog {
    font-size: 12px;
    color: #666;
    background: #fafafa;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.app-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-card-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.app-card-right .qr-wrap {
    width: 90px;
    height: 90px;
    border: 1px solid #eee;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.app-card-right .qr-wrap canvas,
.app-card-right .qr-wrap img {
    width: 80px !important;
    height: 80px !important;
}

.app-card-right .qr-label {
    font-size: 11px;
    color: #bbb;
}

/* ========== Detail Modal ========== */
.detail-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 800;
    justify-content: center;
    align-items: center;
}

.detail-overlay.show { display: flex; }

.detail-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 420px;
    max-width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.detail-modal .detail-icon {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 16px;
}

.detail-modal .detail-name {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.detail-modal .detail-version {
    font-size: 13px;
    color: #999;
    margin-bottom: 20px;
}

.detail-modal .detail-qr {
    margin: 0 auto 16px;
    display: inline-block;
    padding: 12px;
    border: 1px solid #eee;
    border-radius: 12px;
}

.detail-modal .detail-qr canvas,
.detail-modal .detail-qr img {
    width: 160px !important;
    height: 160px !important;
}

.detail-modal .detail-tip {
    font-size: 12px;
    color: #bbb;
    margin-bottom: 20px;
}

.detail-modal .detail-changelog {
    text-align: left;
    font-size: 13px;
    color: #555;
    background: #f9fafb;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.detail-modal .detail-meta {
    font-size: 12px;
    color: #bbb;
    margin-bottom: 20px;
}

.detail-modal .detail-meta span + span::before {
    content: ' · ';
}

.detail-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 20px;
    color: #ccc;
    cursor: pointer;
}

.detail-close:hover { color: #666; }

/* ========== Login Modal ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 900;
    justify-content: center;
    align-items: center;
}

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

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    width: 360px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal {
    position: relative;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    font-size: 22px;
    color: #ccc;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.modal-close:hover { color: #666; }

.modal h2 {
    font-size: 20px;
    text-align: center;
    margin-bottom: 24px;
    color: #1a1a1a;
}

.modal .form-group { margin-bottom: 14px; }

.modal .form-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.modal .form-group input:focus {
    border-color: #4f8ef7;
    box-shadow: 0 0 0 3px rgba(79,142,247,0.1);
}

.modal .btn-login {
    width: 100%;
    padding: 11px;
    margin-top: 6px;
    font-size: 14px;
    text-align: center;
    justify-content: center;
}

.modal .login-error {
    color: #ff3b30;
    font-size: 13px;
    text-align: center;
    margin-top: 10px;
    min-height: 18px;
}

/* ========== Config Status ========== */
.config-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.config-status.ok { background: #e8f5e9; color: #2e7d32; }
.config-status.no { background: #fff3e0; color: #e65100; }

.config-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.config-status.ok .dot { background: #4caf50; }
.config-status.no .dot { background: #ff9800; }

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #ccc;
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    z-index: 1000;
    transform: translateX(120%);
    transition: transform 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show { transform: translateX(0); }
.toast.success { background: #34c759; }
.toast.error { background: #ff3b30; }

/* ========== Responsive ========== */
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .container { padding: 12px; }
    header { padding: 20px 0 8px; }
    header h1 { font-size: 20px; }
    .upload-area { padding: 28px 16px; }

    .navbar { flex-direction: column; gap: 12px; }

    .app-card { flex-direction: column; }
    .app-card-right { flex-direction: row; gap: 12px; }
    .app-card-right .qr-wrap { width: 70px; height: 70px; }
    .app-card-right .qr-wrap canvas,
    .app-card-right .qr-wrap img { width: 60px !important; height: 60px !important; }

    .detail-modal { padding: 24px; }
    .detail-modal .detail-qr canvas,
    .detail-modal .detail-qr img { width: 120px !important; height: 120px !important; }
}
